To simply show the titles of the articles inside the category "Dogs":
{articles category="Dogs"}
[title]
{/articles}
You can display any data attached to the article..
For example, [id]
will output the ID of the category, while [alias]
will output the alias.
You can also output the [url]
to the article, and automatically link to the full article page with:
[link][title][/link]
To show the name of the user that wrote the article, you can do:
[author-name]
Check out the Full List of Data Types available for every article data at your disposal.
Full Article
The [article]
tag will render the Full Article the way your template does in the default article page. Generally that includes the title, text and some meta data, like the author and published date (depending on your settings).
So if you want to output the complete article, you can do:
{article title="Modern Persian Cat"}[article]{/article}
But if you place nothing between the opening and ending tags, the full article will be used too. So this also works:
{article title="Modern Persian Cat"}{/article}
List of Data Tags
Syntax | Example | Description |
---|---|---|
article | Show Example | The entire article as displayed in the article view. See the Full Article section for a full explanation. |
title | Apples | The title of the article. |
alias | apples | The alias of the article. |
id | 12 | The ID of the article. |
text introtext fulltext | Show Example | The full text or the intro text of the article. See the Text section for a full explanation. |
category | Fruit | The category that the article belongs to. |
author | Peter Van Westen | The author of the article (the "Created by" user). A lot more category data is available with author:... - see the User Data below for more details. |
modifier | Andy | The article modifier (the "Modified by" user). A lot more category data is available with modifier:... - see the User Data below for more details. |
image-intro | The intro image of the article. A lot more image data is available - see the Images & Videos section below for more details. | |
image-fulltext | The full article of the article. A lot more image data is available - see the Images & Videos section below for more details. | |
is-published | true | A true/false value based on whether the article is published or not. This also takes into account the publish-up and publish-down dates. |
created publish-up publish-down modified | Wednesday, 5 February 2020 16:00 | The create, publish and modify dates. The date format can be customized. See the Dates section for a full explanation. |
is-featured | false | A true/false value based on whether the article is set as featured or not. This also takes into account the featured-up and featured-down dates. |
featured-up featured-down | Monday, 15 June 2020 19:00 | The featured up and down dates (If the article is set as featured). The date format can be customized. See the Dates section for a full explanation. |
has-access | true | A true/false value based on whether the visitor/logged-in user has access to the article. |
ordering | 5 | The ordering position of the article in the "Articles" manager. |
featured-ordering | 3 | The ordering position of the article in the "Featured Articles" manager (If the article is set as featured). |
hits | 712 | The number of views that the article received. |
url | /fruit/apples | The URL to the article (you can also use sefurl in special cases). |
[link]...[/link] | Apples | Opening and closing tag to add a link to the article (wraps the content with an a href tag). |
[readmore] | Read more: Apples | A "read more" button that links to the full article. See the Read more section for a full explanation. |
[edit] PRO | Edit | A link to the article editing page. See the Edit Link section for a full explanation. |
tags PRO | The tags attached to the article. See the Tags section for a full explanation. | |
my-custom-field PRO | Green | The value of any Custom Field attached to the article. Use the name of the desired field, for example: [color] .A lot more custom field data is available - see the Custom Fields section for a full explanation. |
language metadesc metakey etc. | ... | Any other article data. It must match the name of the columns available in the database. |
meta-robots meta-author meta-rights 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- |
urla urlb urlc etc. | ... | Any attribute related to the links from the "Images and Links" tab. It must match the attribute name in the urls database column. |
show_title show_category show_author etc. | true | Any attribute related to "Options" tab. It must match the attribute name in the attribs database column (you can replace the underscores with dashes). These can be particularly useful in If Structures. |
Alternative Layout
As you may know, in Joomla you can create alternative layouts for your articles. If you are not familiar with layout overrides, check out the dedicated tutorial on Layout Overrides in Joomla.
To give you a short overview, the default layout used to render articles is located at this path:
/components/com_content/views/article/tmpl/default.php
You can use this default file as your starting base, copy this file to templates/[my template]/html/com_content/article/my-layout-name.php
, and edit the code to meet your needs.
Now, in the data tag, you can set to use the alternative article layout by simply inserting the name of the file in the layout="..."
attribute:
[article layout="my-layout-name"]
You can also use the layout from a different template, by specifying the template where it resides with the format template-name:layout-name
:
[article layout="protostar:my-layout-name"]
Adding or overriding attributes J4
In addition to using an alternate layout, you can also control the output of the article by adding or setting extra attributes inside the data tag.
You can override any of the settings found in the "Options" tab of an article. For example, to hide the author from your article display, you could use show_author="false"
.
This is the full list of attributes you can override in the [article]
data tag, in most cases by giving a value of either true
or false
:
Syntax | Description |
---|---|
layout or article_layout | Use a layout from the supplied component view or overrides in the templates. |
show_title | Show Title |
show_tags | Show Tags |
show_intro | Show Intro Text |
info_statement_position | Position of Article Info |
info_statement_show_title | Show Article Info Title |
show_category | Show Category |
link_category | Link Category |
show_parent_category | Show Parent Category |
link_parent_category | Link Parent Category |
show_author | Show Author |
link_author | Link to Author's Contact Page |
show_create_date | Show Create Date |
show_modify_date | Show Modify Date |
show_publish_date | Show Publish Date |
show_item_navigation | Show Navigation |
show_vote | Show Voting |
show_hits | Show Hits |
show_noauth | Show Unauthorized Links |
urls_position | Position of the Links |
alternative_readmore | Read More Text |
Note: the attribute must match its name in the attribs database column (you can optionally replace the underscores with dashes).