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

Users Anywhere offers several numbers based on what place the user has in the list of users. 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 user in the list, If this is the "first" or "last" user, if it's an "even" or "uneven" user, etc...

Note: If you use Pagination, the Numbers values will be based on the users 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 users returned by the {users} tag on the page.

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

When you use the limit="..." attribute, to - for instance - only return 40 users overall, then you might also want to know (and use) the total number of users 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 user in that set of users.
So the first user on the page will have a count value of 1. The seventh user 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-user-[count]">[title]</div>

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

{users usergroup="Customer"}[link][title][/link]
{if count <= 3}[introtext]{/if}{/users}

If you use pagination, you can get the overall number of the user with the count-no-pagination value.
So, if you show 10 users per page, the first user 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 user in the list. This will return the number of the last user when the current is the first on the page.

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

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

<p>{users usergroup="Customer"}</p>
<h1><a href="/user-[count]"></a>[title]</h1>
<p>[text]</p>
<p><a href="#user-[previous]">previous</a> <a href="#user-[next]">next</a></p>
<p>{/users}</p>

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

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

Is First / Last

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

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

<div class="my-user {if is-first}my-first-user{/if} {if is-last}my-last-user{/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 user.

If you use pagination, you can get the overall first and last user with the is-first-no-pagination and is-last-no-pagination values.
So the is-last value will be true for every last user in each page, while the is-last-no-pagination value will only be true for the very last user 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 users in the output (in html view):

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

The same can be done with an else:

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

Or even shorter with the same result:

<div class="my-user my-user-{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 users.

Every ...

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

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 user 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 user.
  • The is-3-of-3 value will be true for the 3rd, 6th, 9th, etc user.
  • And the is-2-of-5 value will be true for the 2nd, 7th, 12th, etc user.

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

<div class="my-user {if is-2-of-5}my-special-user{/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 users 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

Users 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 Users Anywhere with pagination, to show users from the "Animals" category, which has a total of 75 users. But we're only showing 10 users per page, with an overall limit of 40:

{users usergroup="Customer" limit="40" per-page="10"}...{/users}

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

Current Page Numbers

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

SyntaxExampleDescription
total 10 The total number of users returned on the page. This also equals to the count of the last user.
count 3 The number of the current user in the list of users on the page.
previous 2 The number of the previous user on the page. This will return the number of the last user when the current is the first.
next 4 The number of the next user on the page. This will return the number of the first user (1) when the current is the last.
limit 40 The maximum number of users set to be returned.
offset 0 The offset when showing a range of users not starting from the start.
per-page 10 When using pagination, the number of users 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 user is the user 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 user is the first/last in the list of users on the page.
is-even
is-uneven
false / true A true or false value based on whether the current user is an even/uneven user in the list of users on the page.
has-next
has-previous
true / true A true or false value based on whether there is a next/previous user on the page (so can be false for first/last users).
every-... true A true or false value based on the number of the user in the list of users. For example every-3.
is-...-of-... false A true or false value based on the number of the user in the list of users. 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 users before pagination is applied. This also equals to the count-no-pagination of the last user.
count-no-pagination 13 The number of the current user in the list of users, regardless of pagination.
previous-no-pagination 12 The number of the previous user regardless of pagination. This will return the number of the last user when the current is the first.
next-no-pagination 14 The number of the next user regardless of pagination. This will return the number of the first user (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 user is the first/last in the list of users.
is-even-no-pagination
is-uneven-no-pagination
false / true A true or false value based on whether the current user is an even/uneven user in the list of users.
has-next-no-pagination
has-previous-no-pagination
true / true A true or false value based on whether there is a next/previous user (so can be false for first/last users).

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 users before limit is applied. This also equals to the count-no-limit of the last user.
count-no-limit 13 The number of the current user in the list of users, not considering limit or offset.
previous-no-limit 12 The number of the previous user. This will return the number of the last user when the current is the first.
next-no-limit 14 The number of the next user. This will return the number of the first user (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 user is the first/last in the total list of users.
is-even-no-limit
is-uneven-no-limit
false / true A true or false value based on whether the current user is an even/uneven user in the total list of users.
has-next-no-limit
has-previous-no-limit
true / true A true or false value based on whether there is a next/previous user (so can be false for first/last users).