if_category
The if_category tag is a conditional tag and always used as an opening and closing pair, like this…
<txp:if_category>
...conditional statement...
</txp:if_category>
The tag will execute the contained statements if the name attribute matches a category search value, or the list is an article list by category (?c=category)
Should be used in a page template; if checking the category in an article form, use if_article_category.
attributes
name="unset"
type="article"
genealogy
Version 4.3.0
Display info depending on list category
<txp:if_category name="prose">
<p><txp:author /></p>
</txp:if_category>
What this does…
Displays the author’s name if the article list is of category “Prose”.
Other tags used: author
Use tag with else
<txp:if_category name="prose">
<p><txp:category /></p>
<txp:else />
<h3><txp:site_name /></h3>
</txp:if_category>
What this does…
Displays the category name if the article list is of category “Prose”, otherwise show the site’s name.
Display an appropriate heading
<txp:if_category>
<h3>Articles in category <txp:category title=1 />:</h3>
<txp:else />
<h3>All articles:</h3>
</txp:if_category>
What this does…
Displays an appropriate heading for both category and non-category pages.
Display a category / article list
Given the defined article categories: Prose, Poetry, and Opinions.
<txp:category_list label="Category Navigation" wraptag="p" class="list" />
<txp:if_category name="prose">
<txp:recent_articles label="Prose" limit="25" break="br" wraptag="p" class="list" category="prose" />
</txp:if_category>
<txp:if_category name="poetry">
<txp:recent_articles label="Poetry" limit="25" break="br" wraptag="p" class="list" category="poetry" />
</txp:if_category>
<txp:if_category name="opinions">
<txp:recent_articles label="Opinions" limit="25" break="br" wraptag="p" class="list" category="opinions" />
</txp:if_category>
What this does…
Shows a category list and, underneath it, a list of related articles in the currently selected category. Changing the category using the list changes the related articles underneath.
Styles could go this way:
p.list
{
font-family: Verdana, "Lucida Grande", Tahoma, Helvetica;
font-size: 11px;
color:#333;
margin-left: 10px;
border-left: 3px solid #ccc;
}
p.list a
{
color:#333;
margin-left:15px;
}
p.list a:hover
{
border-bottom: 1px dashed #333;
}
Other tags used: category_list, recent_articles