Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
[Solved] <txp:if_category number="2">
I know that attribute doesn’t exist, but I sure wish it did. I want to setup conditional output so that if two categories are used, both are output to show what the two categories are for a given article. If not, then only the first one.
For example, let’s say category1
= twigs and category2
= berries.
Then we’d get one category if only cat 1 and both categories if cat 2 also existed:
Using the imaginary attribute, number="2"
, a conditional cluster like this could make it work…
Put in <a class="capitalize" href="/topics/<txp:category1 />"><txp:category1 title="1" /></a><txp:if_category number="2">& <a class="capitalize" href="/topics/<txp:category2 title="1" />"></txp:if_category>.
Is there any other way to do this? Can this attribute be a feature request if not?
Offline
Re: [Solved] <txp:if_category number="2">
Destry wrote #279314:
I want to setup conditional output so that if two categories are used [snip]
So you probably want to look at <txp:if_article_category>
then, which does have the number
attribute :-) Through judicial use of some txp:variable / txp:if_variable you could even make your own tag for it if you like, but there’s probably not much need unless you want to do some super-crunjo extra processing or clever output.
Does that help at all?
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
Re: [Solved] <txp:if_category number="2">
Heh… I believe that does help. Thanks, sire.
Offline
Re: [Solved] <txp:if_category number="2">
Destry wrote #279314:
Put in <a class="capitalize" href="/topics/<txp:category1 />"><txp:category1 title="1" /></a><txp:if_category number="2">& <a class="capitalize" href="/topics/<txp:category2 title="1" />"></txp:if_category>.
Is there any other way to do this? Can this attribute be a feature request if not?
<txp:variable name="cat2" value='<txp:category2 title="1" />' />
<txp:if_variable name="cat2" value="">
<txp:else />
&<a class="capitalize" href="/topics/<txp:category2 title="1" />">...
But Stef’s method is more efficient I believe:)
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] <txp:if_category number="2">
Yes, it’s effectively squared away using <txp:if_article_category>
. Thanks.
Offline
Pages: 1