Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2023-12-15 12:48:59
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,304
category1 and category2 together
i have news frontpage. if i post news into ‘boys’ and ‘girls’ categories, output should look:
…| Kat: Boys, Girls
my code:
<span class=“posted”><txp:posted format=”%d.%m.%Y” /> | Kat: <txp:category1 section=’<txp:section />’ title=“1” link=“1” /></span>
Offline
Re: category1 and category2 together
You need to also use txp:category2 and with the help of txp:evaluate or the wraptag=", <+>"
attribute (this may be txp4.9 only, I can’t remember), you can show it conditionally with a comma:
<span class="posted">
<txp:posted format="%d.%m.%Y" /> |
Kat: <txp:category1 section='<txp:section />' title="1" link="1" /><txp:evaluate test="category2">, <txp:category2 section='<txp:section />' title="1" link="1" /></txp:evaluate>
</span>
or
<span class="posted">
<txp:posted format="%d.%m.%Y" /> |
Kat: <txp:category1 section='<txp:section />' title="1" link="1" /><txp:category2 section='<txp:section />' title="1" link="1" wraptag=", <+>" />
</span>
TXP Builders – finely-crafted code, design and txp
Offline
Re: category1 and category2 together
There is yet another way:
<txp:category_list categories='<txp:category1 />, <txp:category2 />' break=", " trim>
<txp:category title link />
</txp:category_list>
Offline
Re: category1 and category2 together
etc wrote #336162:
There is yet another way
All excellent suggestions. That <+>
is so handy sometimes.
Oleg’s is what I’d use for simplicty because it also allows you to add label=" | Kat: " labeltag="span"
(or whatever), so the label only shows up if there’s at least one category set.
I love these global attributes.
Last edited by Bloke (2023-12-15 22:13:38)
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
#5 2023-12-19 10:34:34
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,304
Re: category1 and category2 together
etc wrote #336162:
There is yet another way:
<txp:category_list categories='<txp:category1 />, <txp:category2 />' break=", " trim>...
brilliant!
Offline
Pages: 1