|
| |
|
|
matis
Posts: 1 Joined: 9/5/2008 From: Rotterdam (The Netherlands) Status: offline
|
(PHP) Read url if else statement - 9/5/2008 8:46:13
Hi all, I'm new here. I am Matis and I am from Rotterdam, The Netherlands. I am a freelance designer and not so much a coder. This is sometimes a problem for me as I have assignments where I have to do both. Hopefully I can find some useful help here. So my first problem: I'm working on a site with a CMS (Drupal). It is a multilingual site with a flash header which contains the main menu items like Products and About us. I have made two different swf movies. One for each language. (header_en.swf and header_nl.swf) So that if you are viewing the site in dutch you'll see the dutch swf menu. The url of a specific page (on my local testing server) looks like this: http://localhost/servername/?q=node/2 (For English pages) and http://localhost/servername/?q=nl/node/2 (For Dutch translation) Now I want to implement an if else statement in php that looks at the url of the page. If it contains '?q=nl' then it should load the dutch swf and if it doesn't the english swf. I read a similair topic here. Can anyone help me with this problem? I'm a PHPn00b so the biggest problem for me is the syntax. Thanks in advance, Matis
|
|
|
|
Mane
Posts: 105 Joined: 7/7/2005 Status: offline
|
RE: (PHP) Read url if else statement - 9/5/2008 16:49:29
Hi. Welcome to the forum! I'm not sure if you really need to read the URL for that particular problem. If there is some information like ?foo=blah after the URL, it is passed to PHP as a variable, in the $GET array. This is one of the ways to send information from page to page. If I understand correctly all you have to do is use that variable in a conditional (if/else) statement: <?php
if ($GET['q'] == 'nl') {
//Dutch
}
else {
//English
}
?> Actually, in case q= is not set, it would be better to change that first line to something like if (isset($GET['q']) && $GET['q'] == 'nl') {This checks to make sure that the variable 'q' exists first, which can prevent an error. I'm not sure about the /node/2 at the end, though. Should this be part of the variable?
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|