Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-06-14 06:23:15
- claudio
- New Member
- Registered: 2005-12-19
- Posts: 6
comma-separated list of categories for an article
Just a little trick that I hope can be helpful to someone else: I wanted to display the list of categories (1 and 2) an article belongs to, separating the categories’ names with a comma in case both are set, i.e.:
Categories: articles
Categories: articles, documentation
I got this by inserting a bit of php code inside my form:
Categories: < txp:category1 link=“y” />< txp:php>
global $thisarticle;
if ($thisarticle[‘category1’] && $thisarticle[‘category2’]) {echo “, “;}
< /txp:php>< txp:category2 link=“y” />
Greetings
C.
Last edited by claudio (2006-06-14 06:24:16)
Offline
#2 2006-06-15 00:58:50
- NyteOwl
- Member

- From: Nova Scotia, Canada
- Registered: 2005-09-24
- Posts: 539
Re: comma-separated list of categories for an article
Neat Trick! I did it slightly differently using just TxP tags.
<code>
<txp:if_article_category name=” “ number=“1”>
<txp:else />
<span class=“posted”><txp:category1 link=“1” /></span>
</txp:if_article_category>
<txp:if_article_category name=” “ number=“2”>
<txp:else />
, <span class=“posted”><txp:category2 link=“1” /></span>
</txp:if_article_category>
</code>
Obsolescence is just a lack of imagination. / 36-bits Forever! / #include <disclaimer.h>;
Offline