grahambayne Posted February 18, 2013 Share Posted February 18, 2013 Hello all, Sorry to join and ask a question immediately. I have just been asked to help out adding some new languages to a website. There is some php working to help the redirects on the pages. I have attached a snippet below and the php file. Currently the only pages it allows you to change to are italian (from the English pages) I am sure this is really simple but I am having trouble getting my head around it and adding two new language directories. I could replace everything with standard HTML links but the php is obviously a better way to do it and it is about time I learnt it. Any help or pointers as to what is happening here would be massively appreciated. Thanks Graham <a href="transporter.php?l=it/index.html" id="view_it"><img src="images/flag_it.jpg" alt="Site in Italian" title="Site in Italian" /></a> or <a href="../transporter.php?l=index.html" id="view_uk"><img src="../images/flag_uk.jpg" alt="Site in English" title="Site in English" /></a> transporter.php Link to comment https://forums.phpfreaks.com/topic/274645-multi-language-site-php-assisted-page-redirects/ Share on other sites More sharing options...
grahambayne Posted February 22, 2013 Author Share Posted February 22, 2013 I have added the php code below as I noticed no one had looked at the file. I just wondered if it was better to post it in case that was the way I should have posted it originally. Any help would be really appreciated, again sorry for jumping straight in with a question. I have ordered O'Reilly PHP so with a little luck I will be able to answer this myself in a few weeks. Thanks Graham <?php /* Because IE doesn't support HTTP_REFERER we have to use ugly GET strings $ref = $_SERVER['HTTP_REFERER']; $ref_parts = explode('/', $ref); $page = $ref_parts[count($ref_parts) - 1]; $dir = $ref_parts[count($ref_parts) - 2]; if($dir == 'it'){ header("location:" . $page); exit(); } else{ header("location:it/" . $page); exit(); } */ if(isset($_GET['l']) && !empty($_GET['l'])){ header("location:" . trim($_GET['l'])); exit(); } ?> Link to comment https://forums.phpfreaks.com/topic/274645-multi-language-site-php-assisted-page-redirects/#findComment-1414183 Share on other sites More sharing options...
jazzman1 Posted February 22, 2013 Share Posted February 22, 2013 I'm using sessions for one my project - http://www.stdimitar.org It works very well. bulgarian.php <?php session_start(); $_SESSION['lang'] = null; header('Location:stdimitar/'); exit; ?> english.php <?php session_start(); $_SESSION['lang'] = 'en'; header('Location:stdimitar/'); exit; ?> index.php (controller) $lang = ($_SESSION['lang'] == 'en') ? 'en' : null; That's all and very simple Link to comment https://forums.phpfreaks.com/topic/274645-multi-language-site-php-assisted-page-redirects/#findComment-1414196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.