Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-02-13 21:12:25

briefwriter
New Member
Registered: 2014-02-13
Posts: 2

article_custom - need to know number of resulting articles in list

I’m pretty familiar with using txp:article_custom. For several reasons, I need the number of articles my particular txp:article_custom outputs (this is assuming it will be an unknown, so even if I would declare limit="integer", the actual number of resulting articles in the list could be either null, or less than the integer stated).

A solution in php or one using Textpattern tags is acceptable. I searched the forums, and found similar issues, but must have not searched using the correct keywords,

If I had the number of articles a certain txp:article_custom I designed would output, I could then assign that number to a variable. I would go on from there using it effectively for farther queries, etc.

Thanks ahead for any ideas or examples on this.

Offline

#2 2014-02-13 21:19:10

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: article_custom - need to know number of resulting articles in list

You can use rah_function to count. Somewhere in the plugin thread you’ll probably find some examples.

Offline

#3 2014-02-13 21:35:12

etc
Developer
Registered: 2010-11-11
Posts: 5,393
Website GitHub

Re: article_custom - need to know number of resulting articles in list

Hi,

a fast core solution would be calling <txp:php>echo safe_count('textpattern', 'your_SQL_WHERE_clause LIMIT your_offset, your_limit');</txp:php>. There is also many plugin solutions, like

<txp:etc_numpages pageby="1" ...other atts... />

from etc_pagination plugin. It might be more convenient since it takes the same attributes as <txp:article_custom />. You can also count xml elements directly in <txp:article_custom /> output with etc_query plugin.

Last edited by etc (2014-02-13 21:35:41)

Offline

#4 2014-02-13 21:57:50

briefwriter
New Member
Registered: 2014-02-13
Posts: 2

Re: article_custom - need to know number of resulting articles in list

Thanks for the help.

Offline

Board footer

Powered by FluxBB