|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
omexlu Smarty Rookie
Joined: 13 Mar 2014 Posts: 27
|
Posted: Sun Aug 02, 2015 9:28 pm Post subject: Multiple Sprachen |
|
|
Hallo,
Ich habe vor meine Seite in 2 Sprachen darstellen zu lassen:
Code: | $smarty->configLoad('lang/de.conf'); |
Die Frage ist wie kann ich das nun am besten Lösen dass wenn der Besucher auf den Link für Englisch (?lang=en) klickt dass dies irgendwie gespeichert wird sowass der Nutzen nicht bei jedem Seitenaufruf den Link anklicken muss?
Danke im voraus |
|
Back to top |
|
Grizzly Smarty Pro
Joined: 15 Apr 2011 Posts: 172 Location: Germany
|
Posted: Mon Aug 03, 2015 6:06 am Post subject: |
|
|
Hey,
sowas kannst du in Sessions (wenn Browser geschloschen, ist der gespeicherte Wert weg) oder in Cookies (Wert(e) weg, wenn Zeitabgelaufen ist, die du selbst bestimmen kannst oder der Benutzer alle Cookies selbst löscht) speichern und dann bei jedem aufruf auslesen. Wenn nichts vorhanden ist, nimmst du einfach den Standardwert (z. B. Deutsch) |
|
Back to top |
|
omexlu Smarty Rookie
Joined: 13 Mar 2014 Posts: 27
|
Posted: Mon Aug 03, 2015 6:34 am Post subject: |
|
|
Hast du ein Beispiel, gin ziemlich neu in der php scene |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Aug 03, 2015 7:19 pm Post subject: |
|
|
Ich würde es zunächst einmal mit Cookies probieren.
Siehe http://php.net/manual/de/features.cookies.php
Der Code könnte so aussehen (nicht getestet)
Code: | $lang = 'de';
if (isset($_GET['lang'])) {
$lang = $_GET['lang'];
setcookie('lang', $_GET['lang'], time()+60*60*24*30);
} elseif (isset($_COOKIE['lang'])) {
$lang = $_COOKIE['lang'];
} |
time()+60*60*24*30 gibt an dass das Cookie 30 Tage lang gültig sein soll. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|