Textpattern CMS Template Tags

<txp:if_first_category /> container tag, 0 attributes

if_first_category

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

<txp:if_first_category>
...conditional statements...
</txp:if_first_category>

The tag will execute the contained statements if the current category (usually one inside the container or form of a category_list) is the first in the currently displayed list.

genealogy

Version 4.0.7

  • Added as a new tag.
<txp:if_first_category /> 1 examples

Identify 1st cat in category_list

<txp:category_list parent="group-1" children="0">
  <txp:if_first_category>
    <h3><txp:category /></h3>
  <txp:else />
    <txp:category link="1" />
  </txp:if_first_category>
</txp:category_list>

What this does…
Prevents the first category in the list from being hyperlinked to a category page

Why you might do it…
If you nest categories under a ‘header’ category you might want to show the header of the group but not allow people to link to its category page

Other tags used: category_list, category, else