<txp:if_article_category /> container tag, 2 attributes

if_article_category

The if_article_category tag is a conditional tag and always used as an opening and closing pair, like this…

<txp:if_article_category>
...conditional statement...
</txp:if_article_category>

It will execute the contained statement if the category name associated with a particular article (Category1 or Category2) matches the values of the name and number attributes. Should be used in an article form.

attributes

name="unset" 
  • Comma-separated list of category names to match.
number="unset" 
  • match category in Cat1 or Cat2.
  • Values: 1 or 2
<txp:if_article_category /> 3 examples

Display matched category

<txp:if_article_category name="Prose" number="1">
	<p><txp:category1 /></p>
</txp:if_article_category>

What this does…
If the Category1 assigned to the article is “Prose”, the category is displayed.

Other tags used: category1

Using the tag with else

<txp:if_article_category name="Prose" number="1">
	<p>Fun With Prose</p>
<txp:else />
	<p><a href="index.php">Home</a></p> 
</txp:if_article_category>

What this does…
Displays the welcome text if the category and category number match the given values, or shows a default link otherwise.

Other tags used: else

Display a list of matching links

In an article form, put the following set of conditionals for each category you want to look for:

<txp:if_article_category name="yourcategory" number="1">
<ul>
	<txp:article_custom form="sub" category="yourcategory" sortby="Posted" sortdir="asc" />
</ul>
</txp:if_article_category>

And then your article form (in this case called ‘sub’) can be used to list links to other articles like this:

<li><txp:permlink><txp:title /></txp:permlink></li>

What it does…
Lists articles of the same category as the current article’s Category1

Other tags used: article_custom, else, title, permlink