Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Is there a better way ? txp_if conditionals
I have the following in my default page template
<html lang="en"<txp:if_author><txp:else /><txp:if_category><txp:else /> class="front"</txp:if_category></txp:if_author>>
Basically, this says: stick a class on the html element, but only if and when we are really, I mean really, on the front page of the site (example.com/index); if a category or an author page are displayed, do nothing. Other sections and search have their own templates anyway.
The question is: is there an easier, more readable way than this cascading of txp_if … txp:else
statements ? I have similar thingies elsewhere in the template, and I’m looking at optimising all this.
Tia.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: Is there a better way ? txp_if conditionals
i know what you’re saying, but i really can’t imagine it being more readable than this. it’s essentially a derivative of:
if (condition) {
statements_1
} else {
statements_2
}
Offline
Re: Is there a better way ? txp_if conditionals
phiw13 a écrit:
is there an easier, more readable way than this cascading of
txp_if … txp:else
statements ?
Yes : soo_if_frontpage
Offline
Re: Is there a better way ? txp_if conditionals
@Elliott – yeah, it is kinda readable – with 2 or 3 levels…
But basically, what I was hinting at: the need for a txp:if_frontpage
tag [*]. Turns out, maybe there is such a thing, in the form of a plugin. Merçi Claire. I’m off to test it out.
[*] I know, more easily said than done, there are various threads scattered around the forums with discussions on the subject of ‘frontpage’ vs ‘default’ template (which is quite a rich animal, the more I dive into it).
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline