Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-06-14 20:39:05

guiguibonbon
Member
Registered: 2006-02-20
Posts: 296

multi-lingual with cookies

Hye everybody,

sorry to bother with a rather annoying question. Client wants an 8 pages website in 4 languages. I figured I could make a section for each page, where there is one article for each language.

There would be the typical landing page where you choose your language, which brings your for instance to www.example.com/TPfolder/HomePageSection/en (the chosen language) which thanks to the chh_related_articles plugin might link to pages with same title (the language).

It would be nice though that the language choice is stored in a cookie, which could enable me to simply link to www.example.com/TPfolder/section/ , which in turn fetches the correct article according to the cookie (hope this makes sence to you). This means I would have inline php on the pages, which looks for the cookie, and sets a default language if he can’t find it.

So finally, the question : how can I use a php value for the title attribute of txp:custom_article ? (I sort of guess this is impossible, since using tags inside attributes is impossible — any workaround?)

Loads of thanks in advance

Offline

#2 2006-06-14 21:06:00

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: multi-lingual with cookies

With you up until this:

…which thanks to the chh_related_articles plugin might link to pages with same title (the language) …how can I use a php value for the title attribute of txp:custom_article?

There is a tag called article_custom, but it doesn’t have a title attribute. But I think I know what you’re asking for. Can you please post the code you’re using right now? Then I can convert it to use a cookie. :)

Offline

#3 2006-06-14 21:19:51

guiguibonbon
Member
Registered: 2006-02-20
Posts: 296

Re: multi-lingual with cookies

oh.. yeah sorry. Too used to using chh_article_custom, which accepts titlearticles. Also, I haven’t started yet… just trying to figure out how much I might charge. But presumably it would be :
<code>
<txp:chh_article_section section=”?” titlearticles=”$lng” />
</code>

“?” means current.

Offline

#4 2006-06-14 21:36:54

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: multi-lingual with cookies

It’d look like this:

<txp:php>

// look for a cookie named lang
// if not found, default is 'en'

$lang = cs('lang') ? cs('lang') : 'en';

// lookup article by lang value

echo chh_article_section(array(
	'section'       => '?',
	'titlearticles' => $lang
));

</txp:php>

:)

Offline

#5 2006-06-14 21:42:55

guiguibonbon
Member
Registered: 2006-02-20
Posts: 296

Re: multi-lingual with cookies

you’re bloody brilliant Mary.

Offline

Board footer

Powered by FluxBB