With Articles Anywhere for Joomla! 4, you can display any data of the author and modifier of the article.
To simply show the name of the user that wrote the article:
{article title="Lions"}[author]{/article}
To simply show the name of the user that last modified the article:
{article title="Lions"}[modifier]{/article}
But you can get more specific! All the author and modifier data can be entered with the author:
and modifier:
prefixes respectively.
For example, [author:id]
will output the ID of the author, while [modifier:alias]
will output the alias of the modifier.
With the Pro version of Articles Anywhere, you can also output data of the currently logged-in user (visitor of the page). This is done with the user:
prefix.
List of Data Tags J4
Check out the Full List of Data Types available for every user data at your disposal.
Syntax | Example | Description |
---|---|---|
author | Peter | The name of the author of the article. If set, the "Created by Alias" will take precedence over the name of the user. |
author:name | Peter Van Westen | The name of the user that is the author of the article (the "Created by" user). |
author:id author:username author:email | peter | The ID, username and email of the author of the article (the "Created by" user). |
author:id-alias | Peter | The alias set in the "Created by Alias" field of the article. |
author:registerDate author:timezone author:lastvisitDate etc. | 2020-11-08 19:07:00 | Any other user data of the author. It must match the name of columns or attributes available in the database. |
modifier or modifier:name | Andy | The name of the article modifier (the "Modified by" user). |
modifier:id modifier:username modifier:email . | andy | The ID, username and email of the article modifier (the "Modified by" user). |
modifier:registerDate modifier:timezone modifier:lastvisitDate etc. | 2020-11-08 19:07:00 | Any other user data of the modifier. It must match the name of columns or attributes available in the database. |
user:id PRO | 465 | The ID of the currently logged-in user (visitor of the page). This will be 0 if the visitor is not logged in. |
| Peter Van Westen, peter | The name, username and email of the currently logged-in user (visitor of the page). |
user:guest PRO | false | A true/false value based on whether the current visitor is a guest (true) or is logged-in (false). |
user:registerDate user:timezone user:lastvisitDate etc. PRO | 2020-11-08 19:07:00 | Any other user data of the logged-in user. It must match the name of columns or attributes available in the database. |
Author Layout J4
By default, Articles Anywhere will output the Author 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:
[author layout="true"]
The default layout used to render it is located at this path:
/layouts/joomla/content/info_block/author.php
Alternatively, in the data tag you are also able to override the default layout with a different one.
You can use this default file as your starting base, copy this file to templates/[my template]/html/layouts/joomla/content/info_block/my-author-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:
[author layout="joomla.content.info_block.my-author-layout"]