Reply to Re: Menu

Your name:

Reply:


Posted by Toby Inkster on 11/26/05 11:18

Luigi Donatello Asero wrote:

> This sounds interesting but it seems to have some disadvantages:
> 1) How could I include different menus this way?
> I would need at least a different menu for each language.

<?php include "menu.php" ?>

where menu.php says:

<ul>
<?php
# what language are we using?
if ($_COOKIE['language'])
{ $lang = $_COOKIE['language']; }
elseif ($_SERVER['HTTP_ACCEPT_LANGUAGE'])
{ $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2); }
else
{ $lang = 'en'; }

# if german, do german menu
if ($lang=='de')
{
print '<li><a href="/home.de.php">Ausgangsposition</a>' . "\n";
print '<li><a href="/help.de.php">Hilfe</a>' . "\n";
print '<li><a href="/contact.de.php">Kontact</a>' . "\n";
}
# if french, do french menu
elseif ($lang=='fr')
{
print '<li><a href="/home.fr.php">Page d'accueil</a>'. "\n";
print '<li><a href="/help.fr.php">Aide</a>' . "\n";
print '<li><a href="/contact.fr.php">Contact</a>' . "\n";
}
# otherwise, english
else
{
print '<li><a href="/home.en.php">Home Page</a>'. "\n";
print '<li><a href="/help.en.php">Help</a>' . "\n";
print '<li><a href="/contact.en.php">Contact</a>' . "\n";
}

# whatever language, off the choice to change language:
print '<li><a href="/setlanguagecookie.php?lang=en">English</a>' . "\n";
print '<li><a href="/setlanguagecookie.php?lang=fr">Francais</a>' . "\n";
print '<li><a href="/setlanguagecookie.php?lang=de">Deutsch</a>' . "\n";
?>
</ul>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация