You can display the tags of an article with the [tags]
tag.
This shows the tags of article "Lions":
{article title="Lions"}[tags]{/article}
By default, the output will be generated through the Joomla layout for tags.
Plain links
If you want to output unstyled simple links to the tags, you can use the layout="false"
attribute.
[tags layout="false"]
Plain text
To output the tags as plain text - so not as links - you can use the links="false"
attribute.
[tags links="false"]
Separator
You can also set a specific separator to place between the tags, by using a separator="..."
attribute inside the data tag. For instance:
[tags separator=" - "]
You can also add last-separator="..."
to use a different separator in between the last 2 elements:
[tags separator=", " last-separator=" and "]
Custom Output for each Tag J4
For even more control over the output of Tags, you can use the Foreach Structure feature. This gives you the ability to fully control the output of each tag assigned to the article.
For example, you could use it to give a custom styling to each tag:
{foreach data="tags"}
<span class="badge-blue">[row]</span>
{/foreach}
Furry Fluffy Fuzzy
The great thing about this feature is that it allows you to output any attribute attached to a Tag. This means that, instead of showing just the name of the Tags, you could output the teaser image of each tag by using [row:image-intro]
:
{foreach data="tags"}
[row:image-intro]
{/foreach}
Read: Using the Foreach Structure to output Tags in a Custom Layout.
List of Data Tags
When using Tags as part of the Foreach Structure, for each tag you can of output its title via [row:title]
, its alias via [row:alias]
, the description text via [row:description]
, etc.
Here are the Data Types available for a Tag when using Tags as part of the Foreach Structure:
Syntax | Example | Description |
---|---|---|
row | Furry | The name/title of the tag, linked to the tag itself. |
row:title | Furry | The name/title of the tag, as plain text without link. |
row:id | 4 | The ID of the tag. |
row:alias | furry | The alias of the tag. |
row:description | ... | The description text of the tag. |
row:url | /tag/furry/ | The URL to the tag (you can also use row:sefurl in special cases) |
[row:link]...[/row:link] | Furry | Opening and closing tag to add a link to the tag (wraps the content with an a href tag). |
row:image-intro row:image-fulltext | The teaser image or full image attached to the tag. | |
row:image-intro:url row:image-fulltext:url | /tag/furry/ | The URL of the teaser image or full image attached to the tag |
row:tag_link_class row:language row:metadesc etc. | badge-blue | Any other data attached to the tag. It must match the columns or attribute names available in the database. |
Alternative Layout J4
Articles Anywhere also allows you to set a different PHP layout for the Tags.
The default layout used to render Tags is located at this path:
/layouts/joomla/content/tags.php
You can use this default file as your starting base, copy this file to templates/[my template]/html/layouts/joomla/content/my-tags-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:
[tags layout="joomla.content.my-tags-layout"]