July 1, 200818 yr Hi, I've got 3 versions of my website in 3 languages. I want 3 little flags on the page. When someone clicks to change the language I want to get the same page but in the other language. Is there a way to get the page name then find that page name in a different folder in the directory with php. E.g. 3 websites, 3 folders, same page names, 3 different languages Pixel English Pixel Georgian Pixel Russian Thanks Andy
July 2, 200818 yr Hi, I have just written this script for you, hope this helps. <?php //sees if a link has been clicked on and the variable set if (isset($_REQUEST['language'])) { //finds out which language has been chosen if ($_REQUEST['language'] == 'l1') { $filename = 'languages/language_1/index.php'; } elseif ($_REQUEST['language'] == 'l2') { $filename = 'languages/language_2/index.php'; } if ($_REQUEST['language'] == 'l3') { $filename = 'languages/language_3/index.php'; } //if a link has not been clicked on and a variable been set then the $filename is set to the default filename } else { $filename = 'languages/default.php'; } ?> <html> <body> <!--the below will remain the same over all the pages, only the include will change--> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?language=l1">Language 1</a> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?language=l2">Language 2</a> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?language=l3">Language 3</a><br /> <!--this will pull the selected content from the selected filename--> <?php include($filename); ?> </body> </html> Mike www.everydayprint.co.uk
July 3, 200818 yr Author Wow! Thanks very much. I appreciate it.. I will use it today. I will post a link to you once the site it up. Thanks Andy
July 9, 200818 yr Author Hi, I need some helping using this. My page has an included header and footer. Where do I put the script? Thanks Andy
July 9, 200818 yr Author I decided to do this instead - <?php $file = basename($_SERVER['SCRIPT_NAME']); ?> <a href="<?php echo '../pixel english/'.$file ?>">english</a><br /> <a href="<?php echo '../pixel georgian/'.$file ?>">georgian</a><br /> <a href="<?php echo '../pixel russian/'.$file ?>">russian</a><br />
Create an account or sign in to comment