Count number of pages based on criteria (section, white/black lists, SQL-condition, include subsections)

The Pagecount plugin enables smart page counting on a Cotonti-powered website. Let's figure out how to use it.

First off, install the plugin.

Now, wherever you need to place a page counter in you TPL file use callback for the pagelist function:

{PHP|pagecount('questions','','','', '1','')}

The parameters passed are as follows:

  1. Section code to calculate pages in
  2. White list to calculate pages in (semicolon separated)
  3. Black list to exclude pages from (semicolon separated)
  4. SQL condition
  5. Include subsections
  6. Lang string name to enable cot_declension

How it works?

In instance, you need to calculate pages in the shop section. Use the following callback for this:


This outputs the plain number of the pages. Let's make the task harder and count pages in the shop и special-offers sections:


How about all pages except the system and news sections? Simple:


While using the Pagecount plugin keep in mind that the first three parameters are mutually exclusive.

Now we count the number of news pages including the subfolders:

{PHP|pagecount('news','','','', '1')}

Finally, same task using the cot_declension function:

{PHP|pagecount('questions','','','', '1','News')}

Make sure you have defined the $Ls['News'] var:

$Ls['News'] = "news,news";

This code outputs something like "635 news"

The Pagecount plugins allows using SQL conditions to output page numbers. This is useful if you need, in instance, to count the pages created by a certain user:

{USERS_DETAILS_ID|pagecount('','','','page_owner = $this')}

This plugin is brought to you by the Seditio webdesign studio

Original post

No comments yet
Only registered users can post new comments