Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: [SOLVED] oui_cookie and site/page languages
How about not deleting the language cookie at all, but setting for example en as its default value? Something like this:
<txp:variable name="lang" value='<txp:php> echo gps("lang"); </txp:php>' />
<txp:if_variable name="lang" value="el" match="exact">
<txp:oui_cookie name="lang" duration="1 year" value="el" />
<txp:else />
<txp:oui_cookie name="lang" duration="1 year" value="en" />
</txp:if_variable>
<txp:oui_if_cookie name="lang" value="el">
<txp:variable name="title" value="Τίτλος σελίδας" />
<txp:variable name="description" value="Περιγραφή σελίδας..." />
<txp:else />
<txp:variable name="title" value="Page title" />
<txp:variable name="description" value="Page description..." />
</txp:oui_if_cookie>
<p><a href="?lang=el">GR</a></p>
<p><a href="?lang=en">EN</a></p>
Offline
Re: [SOLVED] oui_cookie and site/page languages
kuopassa wrote #338002:
How about not deleting the language cookie at all, but setting for example en as its default value? Something like this:
<txp:variable name="lang" value='<txp:php> echo gps("lang"); </txp:php>' />...
<txp:if_variable name="lang" value="el" match="exact">...
<txp:oui_if_cookie name="lang" value="el">...
<p><a href="?lang=el">GR</a></p>...
Thanks so much for the suggestion. Would this mean that all urls will have to be appended with ?lang=el
or ?lang=en
? What happens to pages that have just the txp:article_url
?
Also wouldn’t this confuse the browser as to which language to load when visiting txp:article_url
if both cookies are set?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: [SOLVED] oui_cookie and site/page languages
?lang=el
or ?lang=en
is used only to change language by storing the language code in a cookie. :-) So you don’t need to append that stuff to page URLs.
Offline
Re: [SOLVED] oui_cookie and site/page languages
Thanks so much. Will test.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: [SOLVED] oui_cookie and site/page languages
It works! Thanks so much!
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Offline
Re: [SOLVED] oui_cookie and site/page languages
Here is how it looks in an article:
notextile. <txp:variable name="lang" value='<txp:php> echo gps("lang"); </txp:php>' />
<txp:if_variable name="lang" value="el" match="exact">
<txp:oui_cookie name="lang" duration="1 day" value="el" />
<div lang="el">
p>. <a lang="en" rel="nofollow noindex noodp noydir noarchive nocache" href="?lang=en">Read the original English text.</a>
Λορεμ ιπσθμ δολορ σιτ αμετ, αθι εα πθρτο προμπτα δελεγτθς γθ.
notextile. </div>
<txp:else />
<txp:oui_cookie name="lang" duration="1 day" value="en" />
p>. <a rel= "nofollow noindex noodp noydir noarchive nocache" href="?lang=el">Διαβάστε μετάφραση του άρθρου στα Ελληνικά.</a>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
notextile. </txp:if_variable>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: [SOLVED] oui_cookie and site/page languages
One cookie instead of two, woot. Nice approach, kuopassa.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline