Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How do you list an articles category or categories.
Hey all. This is probably an easy problem to solve but…
I need to list a comma separated list of the categories of an article. If there is not two assigned categories it just lists the 1 without the comma. They need to be links as well that go to the category pages.
Filed under: Fruits, Vegetables
Filed under: Fruits
Last edited by mattmikulla (2008-11-06 17:21:01)
Art Rogue – Fine Art Photography
Offline
Re: How do you list an articles category or categories.
Not tested but with the help of an old but trusted plugin, you may add to an article form. (I am assuming that category 1 will always be populated)
<txp:category1 title="1" link="1" />
<txp:chh_if_data>
, <txp:category2 title="1" link="1" />
<txp:else />
</txp:chh_if_data>
Last edited by colak (2008-11-06 18:38:15)
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: How do you list an articles category or categories.
Humm…Not working. It seems insane that TXP doesn’t include a tag for this standard. Also the link for the plugin isn’t working but I’m sure you wanted me to install chh_if_data.
Also, you are correct to assume that category1 will always be populated.
Art Rogue – Fine Art Photography
Offline
Re: How do you list an articles category or categories.
mattmikulla
Try colak’s code without the <txp:else />
branch. I think that’s confusing the chh_if_data
call because it always has “something” in it (either the category or a non-breaking space).
Scratch that, I’m talking crap.
This sort of thing will be possible in 4.0.7 through judicial use of <txp:variable />
and <txp:if_variable />
. But you’re right, a way of saying “if category1” or “if category2” would be handy.
Last edited by Bloke (2008-11-06 18:23:22)
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: How do you list an articles category or categories.
colak wrote:
Not tested but with the help of an old but trusted “plugin”:Lhttp://forum.textpattern.com/viewtopic.php?id=14163, you may add to an article form. (I am assuming that category 1 will always be populated)
<txp:category1 title=“1” link=“1”>
<txp:chh_if_data>
, <txp:category2 title=“1” link=“1” />
<txp:else />
</txp:chh_if_data>
This should work, because I’ve done it in the past.
I think the problem is just a typo error on the <txp:category1 title="1" link="1">
. It’s missing the closing slash.
Last edited by maniqui (2008-11-06 18:28:42)
Offline
Re: How do you list an articles category or categories.
well caught Julián, corrected above
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: How do you list an articles category or categories.
Yep. That was it. Thank you.
Art Rogue – Fine Art Photography
Offline
#8 2008-11-06 22:46:55
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How do you list an articles category or categories.
You can do it without plugin :)
<txp:category1 link="1" title="1" />
<txp:if_article_category number="2">
, <txp:category2 link="1" title="1" />
</txp:if_article_category>
Offline
Re: How do you list an articles category or categories.
Els, I can’t found that if_article_category
tag on the new Textbook Tag Reference
Offline
#10 2008-11-06 22:59:13
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How do you list an articles category or categories.
if_article_category (under i and under conditional tags)
Last edited by els (2008-11-06 23:00:45)
Offline
Re: How do you list an articles category or categories.
Ok, I couldn’t found it because I just search (with the text finder) for “if_ar…”
Curious, why the underscores have been removed?
Offline
#12 2008-11-07 00:07:49
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How do you list an articles category or categories.
Searching for part of a word doesn’t work there, you need to enter a full page title (both ‘if_article_category’ and ‘if article category’ lead you to the right page).
More on the tag pages renaming here.
Offline