Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-10-23 14:14:59

timstr
New Member
Registered: 2006-12-14
Posts: 6

Conditional txp:category

This is probably very basic stuff, but I haven’t been able to find an answer yet.

I would like to show what categories an article belongs to beneath the article’s title. For this, I’ve added the following line:

<p class="tags">Tags: <txp:category1 title="1" link="1" section="journal" />, <txp:category2 title="1" link="1" section="journal" /></p>

However, this way a comma is displayed even if no categories are set.

What I would like to do is something like:

if ( isset( txp:category1 ) { echo txp:category1; }
if ( isset( txp:category2 ) { echo ', ' . txp:category2; }

Can this be done?

Offline

#2 2009-10-23 14:59:05

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Conditional txp:category

I think you can get if_article_category to do what you want:

<txp:category1 title="1" link="1" /><txp:if_article_category number="2">, </txp:if_article_category><txp:category2 title="1" />

but I haven’t tested this.


Code is topiary

Offline

Board footer

Powered by FluxBB