When using the multiple {articles}
you can also output at any point, just the data from a specific article, by using one of these prefixes before the desired data:
Syntax | Description |
---|---|
this:... |
Any data from the article that is currently displayed, so the article that contains the plugin tag itself. |
next:... |
Any data from the next article in the list of articles returned by the plugin tag. |
previous:... |
Any data from the previous article in the list of articles returned by the plugin tag. |
1:... , 2:... , 3:... , 4:... , etc. |
Any data from a specific article in the list of articles returned by the plugin tag. The data name must be prepended with the respective count number of the article. |
After the prefix, you can then output any of Data Types, so including article data, category data, user data, and custom field values.
You can combine any prefix with any of the data types. Here are a few examples:
this:id
will output the the ID of the current article that contains the plugin tag or is currently displayednext:title
will output the Title of the next article in the listprevious:alias
will output the Alias of the previous article in the list2:title
will output the Title of the second article in the list- You can output any other available article data or custom field (for example:
this:speaker
)
The count
prefixes can be particularly useful, for example, if you want to display data from two (or more) articles side-by-side in a table:
{articles category="Fruit" ordering="ordering ASC" limit="3"}{if is-first}
The best fruit ever is [1:title]. But [2:title] and [3:title] are pretty good too.
{/if}{/articles}
The best fruit ever is Strawberries. But Apples and Bananas are pretty good too.
These prefix can especially be useful in If Structures, for example to highlight the current active article in the list of articles returned by Articles Anywhere.
The following example checks whether the ID of one of the returned articles is the same as the currently displayed article. If it is, we put it in bold text, but we don't add a link to it. We only add a link to it to the other articles, not the one currently being displayed.
<ul>{articles category="My Category"}<li>
{if id = this:id}
<strong>[title] (current)</strong>
{else}
[link][title][/link]
{/if}
</li>{/articles}</ul>
- Apples
- Bananas (current)
- Orange
- Peach
- Strawberries