Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-11-06 17:16:37

mattmikulla
Member
From: Nashville Tennessee
Registered: 2004-08-25
Posts: 281
Website

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

#2 2008-11-06 17:38:48

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

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 />
&nbsp;
</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

#3 2008-11-06 18:16:10

mattmikulla
Member
From: Nashville Tennessee
Registered: 2004-08-25
Posts: 281
Website

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

#4 2008-11-06 18:20:03

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

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

#5 2008-11-06 18:28:12

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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 />
&nbsp;
</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)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#6 2008-11-06 18:36:36

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

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

#7 2008-11-06 18:41:23

mattmikulla
Member
From: Nashville Tennessee
Registered: 2004-08-25
Posts: 281
Website

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

#9 2008-11-06 22:53:54

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

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

#11 2008-11-06 23:18:15

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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?


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

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

Board footer

Powered by FluxBB