Jump to content


Photo

menu problem using $PHP_SELF


  • Please log in to reply
2 replies to this topic

#1 scar5308

scar5308
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 23 October 2006 - 06:04 PM

I am trying to set up a multi lingual web site.
Currently, the following works well as a static menu but I would like to change it to a dropdown menu using if possible, the 'select onchange=' method so the user doesn't have to click on a OK or Select button.

I would also like a message to appear in the drop down in its default state such as 'Select Language'
I have a version at: http://www.webwhiz.c.../langselect.php which doesn't work either.
I asked on the forum for help but nothing so far! (see Help with arrays please: http://www.phpfreaks...c,112413.0.html ) I have tried to sort this out but am not really a coder. The code I have so far is:

<? include_once ("./setstring.inc") ?>
<?= "<a href='" . $PHP_SELF . "?lang=pt-br'>Portuguese</a>" ?> |
<?= "<a href='" . $PHP_SELF . "?lang=fr'>Fran&ccedil;ais</a>" ?> |
<?= "<a href='" . $PHP_SELF . "?lang=en'>English</a>" ?> |
<?= "<a href='" . $PHP_SELF . "?logoff=1'>Logoff</a>" ?>

<? include ( setstring ( 'pt-br', './portuguese.php', 'fr', './french.php', 'en', './english.php') )?>

I wouldn't mind getting either to work properly, both would be a bonus! A virtual beer is on offer for anyone who can help!

#2 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 23 October 2006 - 06:26 PM

Not sure I would go about it this way but, using the variable your passing via url, I suppose one easy approach would be:

<?php

  if($_GET[lang] == 'pt') {include'portuguese.php';}
  elseif($_GET[lang] == 'sp') {include'spanish.php';}
  elseif($_GET[lang] == 'fr') {include'french.php';}
  
  else{include'english.php';}

?>

PHP Ninja

#3 scar5308

scar5308
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 23 October 2006 - 07:33 PM

Thanks for that but I am already using something similar for the initial page.

What I wanted to do was; once the visitor has been directed to the page according to the $_GET[lang] I wanted to give them the option of selecting a different language. All the pages are just templates and the script calls up the various includes etc. according to the language detected from language specific include folders. I then wanted a drop down menu on the main page that would change the language include directory. I would therefore only have one set of pages with just the includes and perhaps some images changing according to the language either selected or detected.

Hope that's clear :-)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users