Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-12-14 23:21:18

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Article list count and index?

I need the number of articles returned by my txp:article_custom tag and I also need the index of each article. For example if three articles are returned the count would be 3 and the first article would be 0, second would be 1 and third would be 2. 1, 2 and 3 would work as well.

Ideas and suggestions?

Something like

<txp:article_custom category="something">
 <txp:if_first_article>
 Total Articles = <txp:count />
 </txp:if_first_article>
 This articles index is <txp:index />
</txp:article_custom>

My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#2 2009-12-14 23:40:46

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Article list count and index?

Set count:

<txp:variable name="count" value="0" />

Count:

<txp:article_custom>
	<txp:variable name="count" />
	<txp:variable name="count" value='<txp:php> echo variable(array("name" => "count"))+1; </txp:php>' />
</txp:article_custom>

If you want to output the article count before the article list. You can:

  • Put that everything inside another variable, so you can output the results in different order as nothing is output just set into variables.
  • Use a plugin to count; rah_function, jmd_count etc. (<txp:rah_function call="safe_count" table="textpattern" where="category1='something' or category2='something'" />).
  • Also plugins are offered to automate the variable counting (including adi_calc and rah_function… well core functions that rah_function can call ehehehe).

Last edited by Gocom (2009-12-14 23:42:46)

Offline

#3 2009-12-22 11:03:51

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355

Re: Article list count and index?

some calculations… – aks_var

Last edited by makss (2009-12-22 11:07:15)


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

Board footer

Powered by FluxBB