ee-garage.com

{exp:nsm_categories:archive}

{exp:nsm_categories:archive
([
    string channel
    string category_group
    string parent_only
    string category
    string style
    string depth
    string target_category
    string enable
    string show_empty
    string category_channel_entry_limit
    string category_orderby
    string category_sort
    string start_at_category
])}

This tag renders the category list in your template. It functions very much like the exp:channel:category_archive and exp:channel:entries tags.

The categories that are returned using this tag-pair can be filtered-down to be as specific or broad as needed. A great way to filter your categories is by specifying category group IDs using the category_group parameter.

Categories can be output as a linear list or nested using the style parameter. A category can be 'targeted' by passing the category ID into the target_category parameter.

By default the tag-data for the channel-entries associated to a category are not included until you add entries to the enable parameter.

When enabled="entries" NSM Categories uses the Channels module to return the relevant channel entries and post-processes the results. Any tag parameter not listed on this page will also be processed by the Channels module. This is important when you start combining the enable="entries" and category_channel_entry_limit="#" parameters. If you wish to order your channel entries by title then you would add the orderby="title" sort="asc" parameters to this opening tag.

Parameters

channel [optional]

channel="foo|bar"

Filter categories by channels. Use pipe-delimited channel names to filter the categories to those assigned to the chosen channels.

category_group [optional]

category_group="1|2"

Filter categories by the category groups. Use pipe-delimited category group IDs to return categories assigned to the chosen category groups.

parent_only [optional]

parent_only=""

Shows parent categories only. Categories that have been assigned to another category as a child will not be output.

category [optional]

category="13|1337"

Shows only the categories specified in the parameter. Use pipe-delimited category IDs to return the chosen categories.

style [optional]

style="linear|nested"

Linear or nested tag-data. Linear tag-data is output in a single-tiered list with categories appearing one after the other. Nested tag-data will use the tag-data encapsulated in the exp:nsm_categories:archive tag-pair and use this as the tag-data for each 'list item'. The child categories will be output in place of the category_children_tagdata tag.

depth [optional]

depth="2"

Limits the category child depth to the chosen value. If depth is set to 2 then categories set 3 or more tiers deep will not be output.

target_category [optional]

target_category="2"

Find a category in the tree. The category that has been targeted and any of its parents will have category_is_target set as true. See category_is_target for more information.

enable [optional]

enable="entries|category_fields"

When entries is set as a value of this parameter the data for the category entries is returned and useable in the category_channel_entries tag-pair. All custom-field data available to the exp:channel:entries tag is useable in the category_channel_entries.

show_empty [optional]

show_empty="no|yes"

Hide empty categories. Only applicable if enable parameter is set to entries.

category_channel_entry_limit [optional]

category_channel_entry_limit="50"

Limits the number of channel entries that are returned per category in the category_channel_entries tag-pair.

start_at_category [optional]

start_at_category="13"

Reduces the categories output to the chosen category its descendants.

category_orderby [optional]

category_orderby="position|title"

Specifies what property is used to order the categories during output. Default value is title.

category_sort [optional]

category_sort="asc|desc"

Specifies the sorting direction of the categories output. Default value is asc.

Single variables

{category_total_results}

{category_total_results}

Outputs the total number of categories.

{channel_entry_total_results}

{channel_entry_total_results}

Outputs the total number of channel entries returned in all categories.

{count}

{count}

Returns the count of the channel entry irrespective of its placement in the tag-data. This is counter that starts at 1 like the standard count tag. This counter is often used in conjunction with channel_entry_total_results to determine an entry's position amongst all of the channel entries.

{category_name}

{category_name}

Displays the name of the category.

{category_id}

{category_id}

Returns the category ID.

{category_group_id}

{category_group_id}

Returns the category group ID that the category is assigned to.

{category_parent_id}

{category_parent_id}

Outputs the ID of the category's parent.

{category_url_title}

{category_url_title}

Returns the URL title of the category.

{category_description}

{category_description}

Outputs the category description.

{category_image}

{category_image}

Outputs the image URL of the category if an image has been assigned.

{category_order}

{category_order}

Returns the number that has been assigned to the category for the category sorting order.

{category_channel_entry_count}

{category_channel_entry_count}

Returns the current entry's count within the current category. This is counter that starts at 1 like the standard count tag.

{category_channel_entries_total_results}

{category_channel_entries_total_results}

Outputs the number of channel entries that use the category. Often used in conjunction with the category_channel_entries tag.

{if "{category_channel_entries_total_results}" == "0"}
<li>No results</li>
{/if}

{category_depth}

{category_depth}

Returns the current depth of the category starting at 1. If a category is a child of another category the depth is 2.

{category_count}

{category_count}

Returns the current category's count amongst all categories. This is counter that starts at 1 like the standard count tag.

{category_children_total_results}

{category_children_total_results}

Outputs the number of categories that have been assigned as children to this category.

{category_branch_count}

{category_branch_count}

Returns the current category's count within the branch. This counter resets to 1 when entering a new branch depth.

{category_branch_total_results}

{category_branch_total_results}

Returns the total categories in the current branch. Often used in conjunction with category_branch_count.

{category_is_target}

{category_is_target}

Returns 0 by default. If the current category matches the ID of the target_category parameter this tag will return 1. This will allow you to 'highlight' a category by combining this tag and conditional tags.

<li class='{if "{category_is_target}" == "1"} targeted{/if}'> ... </li>

{category_is_parent}

{category_is_parent}

Returns 0 by default. If this category is a parent of another category this tag will return 1.

{category_is_target_parent}

{category_is_target_parent}

Returns 0 by default. If the category that has been specified in the target_category parameter is a child or descendent of the current category this tag will return 1.

Variable pairs

{category_children_tagdata}

{category_children_tagdata}

This tag-pair only works when the style parameter is set to nested. All tag-data that is encapsulated by the exp:nsm_categories:archive tag-pair will be used to render each child category in a recursive loop until there are no more children.

// Input template tag-data
<ul>
{exp:nsm_categories:archive 
  style="nested"
}
  <li>
  <strong>{category_name}</strong>
    {if category_children_total_results}
    <ul>
      {category_children_tagdata}
    </ul>
    {/if}
  </li>
{/exp:nsm_categories:archive}
</ul>
// Output HTML
<ul>
  <li>
    <strong>Category 1</strong>
    <ul>
      <li>
        <strong>Category 1.1</strong>
        <ul>
          <li>
            <strong>Category 1.1.1</strong>
          </li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

{category_channel_entries}

{category_channel_entries}
  ...
{/category_channel_entries}

This tag-pair only works when the enable parameter is set to entries. Channel entries assigned the the current category are output using the tag-data encapsulated by this tag pair.

Please note: This variable tag pair does not accept parameters. If you wish to filter or order the channel entries via tag parameters such as the orderby="" parameter you need to put these parameters on the opening {exp:nsm_categories:archive} tag instead. These parameters will be passed to the underlying exp:channel:entries tag we use in memory.

Releases RSS Feed © Copyright 2017 | Policies All prices shown are in Australian Dollars ($AUD) Newism