eday_2010 Posted February 21, 2007 Share Posted February 21, 2007 So here is the issue: I am redesiging 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 on another forum gave me the following advice: 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: <?php $address = __FILE__; ?> ...then wherever you want the link to go (even in other included files) add: <?php 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! Doing that, I would get the following error: Access forbidden! 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. Error 403 localhost 02/20/07 10:39:15 Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8d mod_autoindex_color PHP/5.2.0 And the address bar would show: http://localhost/en/<?php%20echo%20str_replace('/en/',%20'/fr/',%20$address);%20?> my .htaccess has the parsing code in it... AddType application/x-httpd-php .php .html .htm 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. Parsing the javascript file causes the button to just be a nice rollover graphic with no link. Putting the javascript in the actual page doesn't work either. 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); ?>"]); 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/eday2010/domains/wnstudios.ca/public_html/test/fr/New_Page.html after you click the switchy link on http://www.wnstudios.ca/test/en/New_Page.html. I was hoping that switching the en/ to fr/ and vice versa in the path wouldn't be super complicated. If anyone could help, that would be super duper. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/39512-solved-dynamic-link-to-switch-folder-in-site-addresshow/ Share on other sites More sharing options...
TRI0N Posted February 21, 2007 Share Posted February 21, 2007 Well the only easy way I know of doing this is having each page with a simple: <?php //Inside the English Page Have This $page = "/fr/topicsexy.html" ; $button = "French" ; ?> assuming the page is /topicsexy.html. Then have the button form do this with action. <form method="POST" action="<?php echo $page ; ?>"> Then of course inside the French Page you have <?php $page = "/en/topicsexy.html" ; $button = "English" ; ?> That way the button to switch does not need to be changed for the action. for the button <input type="submit" value="French/English" Name="<?php echo $button ; ?>"> Quote Link to comment https://forums.phpfreaks.com/topic/39512-solved-dynamic-link-to-switch-folder-in-site-addresshow/#findComment-190642 Share on other sites More sharing options...
eday_2010 Posted February 21, 2007 Author Share Posted February 21, 2007 I don't understand the button form thing. I already have a button made; it's part of a DHTML menu (they needed one item to have a drop-down sub-menu. The link for the button is within a javascript file that has the links and graphic paths for each button. Unless I can put only the one menu item as a DHTML menu between regular buttons and have everything line up and stay on the same line, I have to keep it as a full DHTML menu. So, where does the button form go? In the "sexytopic.html" page? Quote Link to comment https://forums.phpfreaks.com/topic/39512-solved-dynamic-link-to-switch-folder-in-site-addresshow/#findComment-190723 Share on other sites More sharing options...
eday_2010 Posted February 22, 2007 Author Share Posted February 22, 2007 Maybe I should simplify my post: I need some PHP code that will change the path from www.stuff.com/en/morestuff to www.stuff.com/fr/morestuff, that will work from within a DHTML Menu (inside a javascript file). Quote Link to comment https://forums.phpfreaks.com/topic/39512-solved-dynamic-link-to-switch-folder-in-site-addresshow/#findComment-191244 Share on other sites More sharing options...
eday_2010 Posted February 23, 2007 Author Share Posted February 23, 2007 Scratch everything. I redid the menu in CSS, so there is no Javascript to piss around with. So how do I get <?php $address = __FILE__; ?> in the body of files to work with <?php echo str_replace('/en/', '/fr/', $address); ?> in the one menu button in the include file without it pulling out the whole file have and without it not swapping /en/ for /fr/ and only loading the body file without the included menu? in the one menu button in the include file without it pulling out the whole file have and without it not swapping /en/ for /fr/ and only loading the body file without the included menu? i.e. http://www.wnstudios.ca/test2/en/home.html --> http://www.wnstudios.ca/test2/fr/home.html instead of http://www.wnstudios.ca/home/eday201.../fr/home.html? Quote Link to comment https://forums.phpfreaks.com/topic/39512-solved-dynamic-link-to-switch-folder-in-site-addresshow/#findComment-192278 Share on other sites More sharing options...
eday_2010 Posted February 26, 2007 Author Share Posted February 26, 2007 PROBLEM SOLVED! Here is how it was done: In the menu file this code was put: <?php /** Take care of all scripting variables before hand... */ // Is there French in the Script Name? If so, replace a copy of it with /en/ if ( strstr('/fr/', $_SERVER["SCRIPT_NAME"] ) ) { $swapLanguageURL = str_replace('/fr/','/en/', $_SERVER["SCRIPT_NAME"]); $currentLang = 'french'; } else { // It must be English, so lets swap it with /fr/ $swapLanguageURL = str_replace('/en/','/fr/', $_SERVER["SCRIPT_NAME"]); $currentLang = 'english'; } ?> Then in the button this was put: a href="<?=$swapLanguageURL;?>" ... WOOOOOOOOT!!!! Quote Link to comment https://forums.phpfreaks.com/topic/39512-solved-dynamic-link-to-switch-folder-in-site-addresshow/#findComment-194414 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.