View Full Version : Resolved modifying a URL
SirTom909
03-24-2009, 10:54 AM
Hi everyone
Im running a multi language site using typo3
The url for the site in english is
'www.url.com'
In welsh, its:
'www.url.com&L=3'
is there a PHP script i can use that modifies the url, either adding or removing "&L=3" so that users can switch languages simply by click on a hyperlink?
i would need to embed the PHP into the HTML template which is used by over 50 pages so i am unable to manually code hyperlinks for each page.
many thanks
Tom
Like this:
<a href="url.com?L=3">Welsh</a>
And then in php at the top of the index page:
<?php
if($_GET['L'] == 3){
echo "Welsh";
}
?>
glambert
03-25-2009, 02:30 PM
Hi,
I think the most efficient way of doing this would be to save the user's preference as a session variable or store in a cookie.
<?php
if(isset($_SESSION['language'])){
$language=$_SESSION['language'];
// insert code the that loads the correct language
}
if(isset($_POST['switch_language'])){
$_SESSION['language']=$_POST['language'];
}
?>
<form>
<fieldset>
<legend>Switch Language</legend>
<select name="language">
<option>Choose</option>
<option value="1">English</option>
<option value="2">Spanish</option>
<option value="3">Welsh</option>
</select>
<input type="submit" name="switch_language" value="Switch" />
</fieldset>
</form>
SirTom909
03-26-2009, 09:30 AM
Nile,Glambert - thank you both for your help.
I tried Nile suggestion but it doesnt apply to every page
going to give Glamberts suggestion a try this morning
thanks again :)
Tom
Well, you'd have to change the html to:
<a href="?L=3">Welsh</a>
But glad to help!
It seems your topic is solved... Please set the status to resolved.. To do this:
Go to your first post ->
Edit your first post ->
Click "Go Advanced" ->
Then in the drop down next to the title, select "RESOLVED"
borris83
03-26-2009, 12:45 PM
If you have 'Includes' folder in your site directory, then probably you have some files that contain code which will get loaded in almost each and every page (all the pages which has called that include file using include() function)
If you check those include files, then one of them might be an include file for page header, which will be the right place to add just a html link to switch language.
Usually, all php sites have a folder to save these include files, to save typing.
Anyway, your question is not limited to php, because all you need is to add just one link in each and every page, and you have various other options to do that.
1) If you have a common navigation bar for all pages then you can add the link to switch language there. Usually many site designing programs have an option to create a navigation bar.
2) Or you can modify an existing common link into this link by a tool called 'Search and replace'.. If you google this, you can find this simple free tool.
3) You can simply rename your index page and add a new index page that links to the current index page. The new index page can have a short summary of your site and links to choose the language.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.