Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge from master #213

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified hi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified [email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/themes-delete-obsolete-assets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/themes-menu-selection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 87 additions & 0 deletions tags/items_count
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
layout: document
category: Tags
published: false
title: Items count
description: The items_count tag is a single tag that returns the number of items (articles, images, etc) returned by list tags.
tags:
- Search tags
---

# Items count

**Contents**

* Table of contents
{:toc}

## Syntax

~~~ html
<txp:items_count />
~~~

The **items_count** tag is a *single* tag that returns the number of (live) articles returned by an article tag.

* Wrap with [if_search](/tags/if_search) tags to count search results.
* Use in a regular article list page by wrapping with [if_article_list](/tags/if_article_list) to count articles in that section.
* Use on the front (default) page to count the number of articles in sections with __On default page__ set to Yes.

## Attributes

Tag will accept the following attributes (**case-sensitive**) as well as the {% include atts-global-link.html %}:

`text="text"`
: Text to display with the number of matches.
: **Default:** `articles found`.

`pageby="integer"`
: **Default:** `1`.

## Examples

### Example 1: Display number of search matches or articles in current section

~~~ html
<txp:if_search>
<txp:items_count />
<txp:else />
<txp:if_article_list>
<txp:items_count text="articles" />
</txp:if_article_list>
</txp:if_search>

<txp:article />
~~~

If the visitor is searching for articles, it will show the number of articles that matched the search term (e.g. 5) as follows: `5 articles found`. Otherwise, if Textpattern is displaying an article list, it will display the number of articles like this: `42 articles`.

Note: The [if_search](/tags/if_search) conditional tag is required to recognize actual search results. Without it, the number of articles is returned by default.
{: .alert-block .information}

Other tags used: [article](/tags/article), [if_search](/tags/if_search), [if_article_list](/tags/if_article_list).

### Example 2: Number of matches, using custom text

~~~ html
<txp:if_search_results>
<txp:items_count text="hits" />
</txp:if_search_results>
~~~

Displays the number of articles returned (e.g. 5) as follows: `5 hits`.

Other tags used: [if_search_results](/tags/if_search_results).

### Example 3: Regular (live) article count

~~~ html
<txp:if_article_list>
<txp:items_count pageby="20" text="pages" />
<txp:article limit="20" />
</txp:if_article_list>
~~~

Displays the number of pages in the current section, then displays articles as an article listing, 20 per page.

Other tags used: [article](/tags/article), [if_article_list](/tags/if_article_list).