You can display any data of the category that the article belongs to.
To simply show the name of the category:
{article title="Lions"}[category]{/article}
But you can get more specific! All category data can be entered with the category:
prefix.
For example, [category:id]
will output the ID of the category, while [category:alias]
will output the alias.
With the Pro version of Articles Anywhere, you can also output the [category:url]
, and automatically link to the category page with:
[category:link][category][/category:link]
Parent Category PRO J4
The same exact data can also be output for the Parent Category of an article, by using [parent-category]
instead of [category]
.
For example:
[parent-category:link][parent-category:alias][/parent-category:link]
List of Data Tags
Check out below the Full List of Data Types available for every category data at your disposal.
Syntax | Example | Description |
---|---|---|
category or category:title | Fruit | The title of the category. |
category:id or catid | 4 | The ID of the category. |
category:alias | fruit | The alias of the category. |
category:description | This category includes fruit. | The description text of the category. |
category:ordering | 7 | The ordering position of the category in the "Category" manager. |
category:image PRO | The image of the category. See the Images section for a full explanation and more details. | |
category:url PRO | /fruit/ | The URL to the category (you can also use category:sefurl in special cases). |
[category:link]...[/category:link] PRO | Fruit | Opening and closing tag to add a link to the category (wraps the content with an a href tag). |
category:is-published | true | A true/false value based on whether the category is published or not. |
category:has-access | true | A true/false value based on whether the visitor/logged-in user has access to the category. |
category:language category:metadesc category:metakey etc. | ... | Any other category data. It must match the name of the columns available in the database. |
category:meta-robots category:meta-author etc. | ... | Any attribute related to the Meta Data. It must match the attribute name in the metadata database column and must be prefixed with meta- |
category:category_layout category:image_alt etc. | ... | Any attribute related to "Options" tab. It must match the attribute name in the params database column (you can replace the underscores with dashes). |
The same exact data can also be output for the Parent Category of an article, by using parent-category
instead of category
.
Category Layout J4
By default, Articles Anywhere will output the Category name as plain text.
However, you can decide to show it in the same style used in the full article view, by outputting it through its respective layout:
[category layout="true"]
[parent-category layout="true"]
This would output the Category and Parent Category through their respective default layouts, which are located at these paths:
/layouts/joomla/content/info_block/category.php
/layouts/joomla/content/info_block/parent_category.php
Alternatively, in the data tag you are also able to override the default layout with a different one.
You can use the default layouts listed above as your starting base, copy the file to templates/[my template]/html/layouts/joomla/content/info_block/my-category-layout.php
, and edit the code to meet your needs.
Now, in the data tag, you can set to use the alternative layout by inserting the path to your file starting from the layouts
folder of your template. The subdirectories must be separated with dots:
[category layout="joomla.content.info_block.my-category-layout"]
[parent_category layout="joomla.content.info_block.my-category-layout"]