XRS Posted June 21, 2011 Share Posted June 21, 2011 Hello, At my free time I just want to play with PHP and I'm trying to assume a website with dynamic links and multi language at the same time. I use $_GET to get the language and the page that user wants to load, but I have some problems. The first run doesn't work. After define the language and page it works perfectly. If you could, please see the code I used in the files attached Multi-Language - header.php - Between ln4 and 43. The example links lines 74,75,83,84 Dynamic Links - index.php - Between line 5 and 17 Could you please help me in this way? Thanks in advance. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/240011-dynamic-links-multi-language/ Share on other sites More sharing options...
fugix Posted June 21, 2011 Share Posted June 21, 2011 It would be easier for us if you pasted your code on this thread please. Quote Link to comment https://forums.phpfreaks.com/topic/240011-dynamic-links-multi-language/#findComment-1232892 Share on other sites More sharing options...
XRS Posted June 21, 2011 Author Share Posted June 21, 2011 As I can't edit the thread, here is the code: index.php page ( dynamic links ) $page = (isset($_GET['p']) === TRUE? strtolower($_GET['p']) : ''); switch($page){ case 'music': include("pages/music.php"); break; default: include("pages/main.php"); break; } header.php ( Multi Language) session_start(); header('Cache-control: private'); // IE 6 FIX if(isSet($_GET['lang'])) { $lang = $_GET['lang']; // register the session and set the cookie $_SESSION['lang'] = $lang; setcookie('lang', $lang, time() + (3600 * 24 * 30)); } else if(isSet($_SESSION['lang'])) { $lang = $_SESSION['lang']; } else if(isSet($_COOKIE['lang'])) { $lang = $_COOKIE['lang']; } else { $lang = 'en'; } switch ($lang) { case 'en': $lang_file = 'lang.en.php'; break; case 'pt': $lang_file = 'lang.pt.php'; break; default: $lang_file = 'lang.en.php'; } include_once 'languages/'.$lang_file; Example Links ( Langue Choose: ) <a href="index.php?p=<?php echo $_GET['p']; ?>&lang=uk"><img src="images/uk.png" /></a> <a href="index.php?p=<?php echo $_GET['p']; ?>&lang=pt"><img src="images/pt.png" /> </a> Example Links ( Page Choose: ) <li><a href="index.php?p=main&lang=<?php echo $_GET['lang']; ?>"><?php echo $lang['MENU_HOME'];?></a></li> <li><a href="index.php?p=music&lang=<?php echo $_GET['lang']; ?>"><?php echo $lang['MENU_MUSIC'];?></a></li> Hope this can help Quote Link to comment https://forums.phpfreaks.com/topic/240011-dynamic-links-multi-language/#findComment-1232899 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.