Creating Dynamic PHP Link in.js file
So here is the issue: I am redesigning a site for an organization.The site is bilingual - English and French. The menu at the top and the left side is an HTML page on it's own. All the pages main body of the site call in the menu part with a line of PHP. Here is an example image:
Here is the problem: The button in the menu to get to the French part of the site needs to go to the same page in French that the person was reading in English instead of just going to the home page for the French side. I.E - someone was reading www.site.com/en/sexytopic.html and they click on the French button in the menu; it needs to take them to www.site.com/fr/topicsexy.html instead of just www.site.com/fr/home.html. It needs to go to the French version of every page that someone is reading, and vice versa for French to English.
Someone in another forum gave me the following advice:
I would get the following error:
In the beginning of your "sexytopic.html" document (I'm asuming you've set it up to be parsed by php) insert the following code:
$address = __FILE__;
...then wherever you want the link to go (even in other included files) add:
echo str_replace('/en/', '/fr/', $address);
- this replaces all occurrences of "/en/" in "$address" with "/fr/" - to get the opposite effect, swap the first two variables around!
And the address bar would show:
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8d mod_autoindex_color PHP/5.2.0
my .htaccess has the parsing code in it...
So I don't know why it's doing this. The menu button is part of a DHTML menu, and the actual place where the link for the button is is in a .js file for the menu.
AddType application/x-httpd-php .php .html .htm
Is this what is causing the problems? doing a plain link on a page gets the address bar to display http://www.wnstudios.ca/home/eday201.../New_Page.html after you click the switchy link on http://www.wnstudios.ca/test/en/New_Page.html.
stm_aix("p0i6","p0i1",[2,"","../graphics/buttons/en/francais1.gif","../graphics/buttons/en/francais2.gif",98,30,0,"<?php echo str_replace('/en/', '/fr/', $address); ?>"]);