Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Count articles in a section
I thought this might work:
<txp:variable name="article_count" trim>
<txp:article_custom section='<txp:section />' fields="ID" pgonly pageby limit="999" status><txp:yield item="count" /></txp:article_custom>
</txp:variable>
Alas, it always assigns 1 to the variable. I’m clearly missing something obvious. Any pointers greatly appreciated.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Count articles in a section
When fields
is set, the counters are reset for each group:
<txp:article_custom fields="section" limit="999" status>
<txp:custom_field name="section" /> (<txp:yield item="count" /> articles)
</txp:article_custom>
I think you can get what you need like this:
<txp:variable name="article_count" trim>
<txp:article_custom section='<txp:section />' pgonly status />
</txp:variable>
Offline
Re: Count articles in a section
Hmm, thanks. Makes sense that field counts reset at each change of grouping (I should have picked up on that myself, duh) but your suggestion still yields 1 for me even though there are two articles in the section I’m viewing.
Maybe I need to employ add
? EDIT: Nope.
Last edited by Bloke (2021-11-16 19:16:55)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Offline
Re: Count articles in a section
Ah, I tried valueless pageby
earlier, which didn’t work, but pageby="1"
does.
Thank you so much.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Offline
Pages: 1