Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2008-08-20 02:21:44
- bunnyhero
- New Member
- Registered: 2008-08-12
- Posts: 5
Conditional tag if an article has categories at all?
Hi! Apologies if this has been asked before, but I couldn’t find anything with a quick search…
In the default article form, the current article’s categories are displayed as <p class="tags"><txp:category1 title="1" link="1" />, <txp:category2 title="1" link="1" /></p>
However, if an article has no categories assigned, or only has one category, the comma still shows up.
Is there a way of testing how many categories have been assigned to an article, so the form can Do The Right Thing and not display a comma if is not necessary?
Thanks!
Offline
#2 2008-08-20 03:29:20
- rsilletti
- Moderator
- From: Spokane WA
- Registered: 2004-04-28
- Posts: 707
Re: Conditional tag if an article has categories at all?
Conditional if_article_category tags can probably be arranged in such a way as to prevent the comma from appearing unless there is a second category assigned.
Offline
#3 2008-08-20 20:32:08
- bunnyhero
- New Member
- Registered: 2008-08-12
- Posts: 5
Re: Conditional tag if an article has categories at all?
rsilletti wrote:
Conditional if_article_category tags can probably be arranged in such a way as to prevent the comma from appearing unless there is a second category assigned.
Thanks for the suggestion. However, I cannot seem to use txp:if_article_category
to test for an empty category. Using <txp:if_article_category name="">
doesn’t work. I’m not sure what other value I could try.
Last edited by bunnyhero (2008-08-20 20:33:41)
Offline
Re: Conditional tag if an article has categories at all?
I doubt the trick can be done using txp:if_article_category
For sure, it can be done using the plug-in chh_if_data (a must-to-have-installed txp plugin), or even easier, using jnm_categories
Offline
#5 2008-08-20 21:07:50
- bunnyhero
- New Member
- Registered: 2008-08-12
- Posts: 5
Re: Conditional tag if an article has categories at all?
maniqui wrote:
I doubt the trick can be done using
txp:if_article_category
For sure, it can be done using the plug-in chh_if_data (a must-to-have-installed txp plugin), or even easier, using jnm_categories
jnm_categories looks like exactly what I need! Thanks!!
I will also look at chh_if_data and see what else it can do for me :)
Offline
Re: Conditional tag if an article has categories at all?
Cayse txp:if_article_category
has attribute number
, you can do:
<p class="tags">
<txp:category1 title="1" link="1" />
<txp:if_article_category number="2">
, <txp:category2 title="1" link="1" />
</txp:if_article_category>
</p>
Last edited by Gocom (2008-08-20 23:14:05)
Offline
#7 2008-08-21 02:11:42
- bunnyhero
- New Member
- Registered: 2008-08-12
- Posts: 5
Re: Conditional tag if an article has categories at all?
Gocom wrote:
Cayse
txp:if_article_category
has attributenumber
, you can do:
<p class="tags">
<txp:category1 title="1" link="1" />
<txp:if_article_category number="2">
, <txp:category2 title="1" link="1" />
</txp:if_article_category>
</p>
Ahh… nice! Thank you.
Offline