Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Possible through a variable?
I am doing a lot of if_section checks in order to output different content depending on the section the user is on. This is because I am running a bilingual website with a fairly primitive setup that works well enough (one language has sections named in that language, and the other language as well, that’s how we tell them apart.)
This is resulting in my conditionals to look like this:
<txp:if_section name=",treninzi,vezbe,o-treninzima,saveti,oprema-i-rekviziti,dodaci-ishrani,testovi,galerija-foto,galerija-video,zdrav-zivot,aktuelnosti,health-club,raspored"> <meta name="description" content="Health Club Novi Sad — Klub za vežbanje, teretana, ishrana, saveti, vežbe, i fitness."/> <!-- this is for serbian site --> <txp:else /> <meta name="description" content="Health Club Novi Sad — Fitness Club & Gym, Diet and Nutrition Information, Advice and Exercise Routines."/> <!-- this is for english site --> </txp:if_section>
Is there a way that I could declare a global variable that would allow me to store all my serbian section in it once, and do an if_serbian → do something, else → do something else?
Repeating a list of sections like this makes things quite error prone.
Thanks.
Offline
Re: Possible through a variable?
Yes, you can use adi_variables and set a global variable (under Content > Variables) called serbian-sections
for example, with ,treninzi,vezbe,o-treninzima,saveti,oprema-i-rekviziti,dodaci-ishrani,testovi,galerija-foto,galerija-video,zdrav-zivot,aktuelnosti,health-club,raspored
as the value.
Then, in your pages or modules you put (note the single quotes around the txp:variable
tag) :
<txp:if_section name='<txp:variable name="serbian-sections" />'>
... what to do in the serbian site ...
<txp:else />
... what to do in the english site ...
</txp:if_section>
Last edited by CeBe (2012-08-23 08:03:00)
Offline
Re: Possible through a variable?
I had no idea it could be this easy, I will try it ASAP.
Thanks CeBe!
Offline
Re: Possible through a variable?
Just following up on this, it worked like a charm. Thanks again CeBe.
Offline
Pages: 1