Help?

category

From Textpattern CMS User Documentation

<txp:category />

The category tag can be used as either a single or containing tag. It will display information of the category as defined by the name attribute, or the one currently being viewed. When used as a containing tag, it will turn the contents into a link to the category. Otherwise, it will return plain text.

May be used in any context.

Contents

Attributes

Tag will accept the following attributes (case-sensitive):

class="class name"
HTML class attribute, applied to wraptag. If no wraptag is supplied (and link="1"), the class is applied to the anchor instead.
Default: unset.
link="boolean" (works only in the single tag)
Whether to display as link.
Values: 1 (yes) or 0 (no).
Default: 0.
name="category name"
Display specific category. Note the category name is specified in lower case regardless of how you typed its title in the Category tab. Also note that if you had called your category My Category Name it becomes my-category-name when used in tags.
Default: unset (use current category).
section="section name"
Restricts category search to named section.
Default: current section (for backwards compatibility).
this_section="boolean"
Only link to articles from the current section. section attribute overrides this setting.
Values: 1 (yes) or 0 (no).
Default: 0.
title="boolean"
Whether to display category's title instead of its name.
Values: 1 (yes) or 0 (no, display name).
Default: 0.
type="category type"
Values: article, image, link, file.
Default: article.
url="boolean"
Display plain URL or full link.
Values: 1 (yes) or 0 (no).
Default: 0 (display title or full link, depending on link)
wraptag="tag"
HTML tag (without brackets) to wrap around output.
Default: unset.

Examples

Example 1: Displays the current category name

<txp:category />

Example 2: Display hyperlinked category title

<txp:category title="1" link="1" />

Example 3: Display a specific category's title, hyperlinked

<txp:category name="articles" title="1" link="1" wraptag="p" />

Example 4: Container Example

<txp:category name="book">My books</txp:category>

Genealogy

Version 4.0.7

  • Applies class attribute to the <a> element when wraptag is empty.
  • New attribute, url to output URL only.

Version 4.0.4

  • this_section added.
Translations [?]