Template Tags

Advanced Categories has been deprecated and is no longer for sale or supported. ExpressionEngine 7.4 introduces many of Advanced Categories features as natively to ExpressionEngine.

Advanced Categories is a fieldtype, and as such it works just like any other fieldtype in ExpressionEngine. The following examples assume you created a custom field with the label of "My Category Field", and the field template short name is {my_category_field}

Every Advanced Categories field is a tag pair, and even though it is a field, the tag pair functions almost exactly the same as the {categories}{/categories} tag pair from the {exp:channel:entries} tag (see ExpressionEngine docs).

{exp:channel:entries}
    {title}
    {my_category_field}
        {category_id}
        {category_name}
        {category_image}
        {category_description}
        {category_group}
        {my_custom_category_field_1}
        {my_custom_category_field_2}
        {path="path/to/category/page"}
        {category_total_results} or {total_results}
        {category_count} or {count}
    {/my_category_field}
{/exp:channel:entries}

This tag pair does not have support for the show or show_group parameters

Since it is also a fieldtype you have access to several tag modifiers:

{my_category_field:ids} This will list all the IDs of the categories chosen in the field separated by pipe. For example: 1|2|3. If only a single category is selected, then its output would be that category ID.

{my_category_field:url_titles} This will list all the IDs of the categories chosen in the field separated by pipe. For example: alpha|beta|charlie. If only a single category is selected, then its output would be that category ID.

{my_category_field:category_names} This will list all the IDs of the categories chosen in the field separated by pipe. For example: Alpha|Beta|Charlie. If only a single category is selected, then its output would be that category ID.

All tag modifiers above support the separator="," parameter where you can change the pipe separator to another character of your choice. For example{my_category_field:ids separator=","} will output 1,2,3

If you wanted to see if an entry is assigned to a category you can use a simple conditional:

{exp:channel:entries}
    {title}
    {if my_category_field:ids ~ "/(1|2|3)/"}
        This entry is assigned to either category 1, 2 or 3
    {/if}
{/exp:channel:entries}

Last updated