When using the multiple {articles} tag, you will have a number of articles being output.

Articles Anywhere offers several numbers based on what place the article has in the list of articles. You can output these numbers via Data Tags, and you can also use them in the If Structures.

This way you can conditionally output html/content/data based on these dynamic values, such as: the number of the article in the list, If this is the "first" or "last" article, if it's an "even" or "uneven" article, etc...

Note: If you use Pagination, the Numbers values will be based on the articles returned in the current page. To get the overall Numbers values regardless of pagination, you can append the respective Data Tag with a -no-pagination suffix.

Totals

The total value contains the number of the articles returned by the {articles} tag on the page.

If you use pagination, you can get the overall number of articles returned with the total-no-pagination value.

When you use the limit="..." attribute, to - for instance - only return 40 articles overall, then you might also want to know (and use) the total number of articles that would have been returned if there was no limit. You can get this value with the total-no-limit value.

Count

The count value contains the number of the article in that set of articles.
So the first article on the page will have a count value of 1. The seventh article on the page will have a count value of 7.

You can - for example - use this count tag to create id or class names. In the HTML/code view of the editor, you could place:

<div class="my-article-[count]">[title]</div>

This example will show the linked title and introtext of the first 3 articles, and only the linked title of the rest:

{articles category="Mice"}[link][title][/link]
{if count <= 3}[introtext]{/if}{/articles}

If you use pagination, you can get the overall number of the article with the count-no-pagination value.
So, if you show 10 articles per page, the first article in the second page will have a count value of 1, and a count-no-pagination value of 11.

Previous / Next

The previous value gives the number of the previous article in the list. This will return the number of the last article when the current is the first on the page.

The next value gives the number of the next article in the list. This will return the number of the first article (1) when the current is the last article on the page.

You can use these to create custom article navigation, or simple anchor links to the previous/next articles.
This is an html example of a blog page with previous/next links:

<p>{articles category="My Category}</p>
<h1><a href="/article-[count]"></a>[title]</h1>
<p>[text]</p>
<p><a href="#article-[previous]">previous</a> <a href="#article-[next]">next</a></p>
<p>{/articles}</p>

The has-next and has-previous values will return a true/false value based on whether there is a next/previous article on the page.
This means that has-previous will only be false for the first article on the page, and the has-next will only be false for the last article on the page.

If you use pagination, you can get the number of the overall previous and next articles with the previous-no-pagination and next-no-pagination values.
This means that has-previous-no-pagination will only be false for the first article on the first page, and the has-next-no-pagination will only be false for the last article on the last page.

Is First / Last

The is-first and is-last will return a true/false value based on whether the article is the first/last article on the page.

This example shows how to add a different class name for the first and last articles in the output (in html view):

<div class="my-article {if is-first}my-first-article{/if} {if is-last}my-last-article{/if}">

You can of course use this for other things as well, like conditionally showing extra data or html for the first and/or last article.

If you use pagination, you can get the overall first and last article with the is-first-no-pagination and is-last-no-pagination values.
So the is-last value will be true for every last article in each page, while the is-last-no-pagination value will only be true for the very last article in the last page.

Is Even / Uneven

The is-even and is-uneven values are handy for creating lists that have an alternating class. Like a "zebra-striped" table.

This example shows how to add a different class name for the even and uneven articles in the output (in html view):

<div class="my-article {if even}my-article-even{/if}{if uneven}my-article-uneven{/if}">

The same can be done with an else:

<div class="my-article {if even}my-article-even{else}my-article-uneven{/if}">

Or even shorter with the same result:

<div class="my-article my-article-{if uneven}un{/if}even">

You can of course use this for other things as well, like conditionally showing extra data or html for the even or uneven articles.

Every ...

The every-... values are useful to add extra html or a class name for every n. articles.

Let's say you want to create columns. Then you will need to add extra html or class names to mark the beginning or end of each row.
For this purpose you can use the every-... value.

This example shows how to add an extra closing and opening <div> after every 4th article in the output (in html view):

{if every-4}</div><div>{/if}

Columns

An even more flexible value is the is-...-of-... value.

Just some examples:

  • The is-1-of-3 value will be true for the 1st, 4th, 7th, etc article.
  • The is-3-of-3 value will be true for the 3rd, 6th, 9th, etc article.
  • And the is-2-of-5 value will be true for the 2nd, 7th, 12th, etc article.

This example shows how to add a different class name for every 2nd article when splitting the result in groups of 5:

<div class="my-article {if is-2-of-5}my-special-article{/if}">

See the If Structures section for more information on the {if} tags.

Page Numbers

If you use Pagination, you can output special pagination-based Number Values.

The per-page value contains the number of articles per page set to be returned.

The pages value contains the total number of pages generated by the results. And you can use the page value to return the number of the current page.

The previous-page value gives the number of the previous page. This will return the number of the last page when the current is the first page.
The next-page value gives the number of the next page. This will return the number of the first page (1) when the current is the last page.

The is-first-page and is-last-page will return a true/false value based on whether the current page is the first/last.

The has-next-page and has-previous-page values will return a true/false value based on whether there is a next/previous page.
This means that has-previous-page will only be false for the first page, and the has-next-page will only be false for the last page.

Calculations J4

Articles Anywhere can even do calculations on numeric values! It can't make you coffee yet, but we're working on it.

The calculations work on any data that outputs a numeric value. This means that not only it works on Number data tags such as [total], [count], [next], [previous], etc, but it can also work on things like [hits], and even custom fields.

Here is how it works, using [count] as an example, where [count] is 10. You can use the following arithmetic operators:

[count]				= 10
[count calc="+10"]	= 20
[count calc="-3"]	= 7
[count calc="*3"]	= 30
[count calc="/2"]	= 5
[count calc="%4"]	= 2

List of Data Tags

In the following examples, let's say we're using Articles Anywhere with pagination, to show articles from the "Animals" category, which has a total of 75 articles. But we're only showing 10 articles per page, with an overall limit of 40:

{articles category="Animals" limit="40" per-page="10"}...{/articles}

Let's say we're looking at the 3rd article returned on the 2nd page (so the 13th article overall). This is what the Numbers output would result into:

Current Page Numbers

The following numbers data tags return the corresponding values for the articles displayed on the current page:

SyntaxExampleDescription
total 10 The total number of articles returned on the page. This also equals to the count of the last article.
count 3 The number of the current article in the list of articles on the page.
previous 2 The number of the previous article on the page. This will return the number of the last article when the current is the first.
next 4 The number of the next article on the page. This will return the number of the first article (1) when the current is the last.
limit 40 The maximum number of articles set to be returned.
offset 0 The offset when showing a range of articles not starting from the start.
per-page 10 When using pagination, the number of articles per page set to be returned.
pages 4 When using pagination, the number of pages generated by the results.
page 2 When using pagination, the number of the current page.
previous-page 1 The number of the previous page. This will return the number of the last page when the current is the first.
next-page 3 The number of the next page. This will return the number of the first page (1) when the current is the last.
is-current false A true or false value based on whether the current article is the article that contains the plugin tag itself. Equivalent to: {if id = this:id}
is-first
is-last
false / false A true or false value based on whether the current article is the first/last in the list of articles on the page.
is-even
is-uneven
false / true A true or false value based on whether the current article is an even/uneven article in the list of articles on the page.
has-next
has-previous
true / true A true or false value based on whether there is a next/previous article on the page (so can be false for first/last articles).
every-... true A true or false value based on the number of the article in the list of articles. For example every-3.
is-...-of-... false A true or false value based on the number of the article in the list of articles. For example is-2-of-5.
is-first-page
is-last-page
false / false When using pagination, a true or false value based on whether the current page is the first/last.
has-next-page
has-previous-page
true / true When using pagination, a true or false value based on whether there is a next/previous page (so can be false for first/last pages).

No-Pagination Numbers

The following numbers data tags return the corresponding values before pagination is applied. These will be different from the ones above only if pagination is used:

SyntaxExampleDescription
total-no-pagination 40 The total number of articles before pagination is applied. This also equals to the count-no-pagination of the last article.
count-no-pagination 13 The number of the current article in the list of articles, regardless of pagination.
previous-no-pagination 12 The number of the previous article regardless of pagination. This will return the number of the last article when the current is the first.
next-no-pagination 14 The number of the next article regardless of pagination. This will return the number of the first article (1) when the current is the last.
is-first-no-pagination
is-last-no-pagination
false / false A true or false value based on whether the current article is the first/last in the list of articles.
is-even-no-pagination
is-uneven-no-pagination
false / true A true or false value based on whether the current article is an even/uneven article in the list of articles.
has-next-no-pagination
has-previous-no-pagination
true / true A true or false value based on whether there is a next/previous article (so can be false for first/last articles).

No-Limit Numbers

The following numbers data tags return the corresponding values before limit and offset are applied:

SyntaxExampleDescription
total-no-limit 75 The total number of articles before limit is applied. This also equals to the count-no-limit of the last article.
count-no-limit 13 The number of the current article in the list of articles, not considering limit or offset.
previous-no-limit 12 The number of the previous article. This will return the number of the last article when the current is the first.
next-no-limit 14 The number of the next article. This will return the number of the first article (1) when the current is the last.
is-first-no-limit
is-last-no-limit
false / false A true or false value based on whether the current article is the first/last in the total list of articles.
is-even-no-limit
is-uneven-no-limit
false / true A true or false value based on whether the current article is an even/uneven article in the total list of articles.
has-next-no-limit
has-previous-no-limit
true / true A true or false value based on whether there is a next/previous article (so can be false for first/last articles).