Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-04-27 17:45:14

richtestani
Plugin Author
Registered: 2009-11-08
Posts: 128

Test if article has category set

I’m trying to see if an article has a category set, then if so, use that category for a url scheme.

The following:

<txp:article wraptag="ul" limit="1">
	<div class="krd_section_image">
		<txp:if_individual_article>
			<txp:if_category name="staff">
				category not set <txp:category1 />
				<txp:else />
				category set <txp:category1 />
			</txp:if_category>
			<img src='/assets/images/<txp:category1 />/<txp:article_url_title />.jpg' class="krd_image" />
		<txp:else />
			<img src='/assets/images/sections/<txp:section />.jpg' class="krd_image" />
</txp:if_individual_article>
	</div>
</txp:article>
<txp:output_form form='<txp:section />_list' />

Outputs to be set no matter if the article has that as the category.

<txp:if_category name="">

Removing a name, turns it false.
Any ideas here?

Thanks
Rich

Offline

#2 2011-04-27 17:57:33

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: Test if article has category set

I think that <txp:if_article_category> would better suit your needs.

Offline

#3 2011-04-27 19:40:35

richtestani
Plugin Author
Registered: 2009-11-08
Posts: 128

Re: Test if article has category set

Oh.

I’m sure I knew that ;p
Thanks CeBe

Offline

Board footer

Powered by FluxBB