Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Show an article count for multiple sections
I’ve found a couple of plugins that give article counts for a single section (mdn_count and mem_article_count), but I’d like to display the grand total for a number of sections. Can it be done?
Mark
Offline
Re: Show an article count for multiple sections
Probably using rvm_count or adi_calc in tandem with txp:article_custom, but it may imply querying the database for articles just to count them. Not sure if that is efficient or not. Hope someone can shed some light on this.
Offline
Re: Show an article count for multiple sections
How about jmd_count. Or if none of the above work, you could get your hands dirty with smd_query and see if that can do it :-)
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: Show an article count for multiple sections
@Bloke,
thanks for sharing your knowledge.
I was looking for a solution to count articles on each section, and wouldn’t feel so comfortable using article_custom in tandem with rvm_counter/adi_calc (btw, rvm_counter as it was released won’t work1) nor mdn_count / mem_article_count (they are too old… of course, that shouldn’t mean anything, and if they get the job done, it’s enough… but really old plugins may not be taking advantage of latest TXP features or may break unexpectedly).
1 This modified version of rvm_counter counts things for each hit to the page. The original one counts things on the database, so concurrent hits may affect the count.
Offline
Re: Show an article count for multiple sections
Hi I needed this a week or so ago.
I made a form called article_count containing one line … <txp:adi_calc name=“article_count” add=“1” />
Then use …
<txp:variable name=“article_count” value=“0” />
<txp:article_custom section=“your_section_name” form=“article_count”/>
Geoff
There are 10 types of people in the world: those who understand binary, and those who don’t.
Offline
Re: Show an article count for multiple sections
Thanks, guys, I’ll try out some of your ideas. I’ll be totally lost if I have to do anything with the database, though.
Mark
Offline
Re: Show an article count for multiple sections
there is also mdn_count which I’ve been using for a few years now without any problems.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Online
Re: Show an article count for multiple sections
I have not been able to find a way of using mdn_count to total the count for more than one section. That is, putting in the names of more than one section does not work.
Mark
Offline
Re: Show an article count for multiple sections
mwr wrote:
I have not been able to find a way of using mdn_count to total the count for more than one section. That is, putting in the names of more than one section does not work.
Did you try just using <txp:mdn_count />
? Without the section
or category
parameters which are optional anyway, it should count all articles.
> Edit : I did not test it but if you want to add the articles from a number of sections wouldn’t something like
<txp:php>echo ('<txp:mdn_count section="section1"/>' + '<txp:mdn_count section="section2"/>')</txp:php>
work? Maybe someone with programming skills will help here.
Last edited by colak (2009-04-11 08:08:14)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Online
Re: Show an article count for multiple sections
colak wrote:
<txp:php>echo ('<txp:mdn_count section="section1"/>' + '<txp:mdn_count section="section2"/>')</txp:php>
work? Maybe someone with programming skills will help here.
If you’re using tags in PHP, you need to use the functions or parse them. So this may be what you want (untested – unfamiliar with mdn_count):
<txp:php>
echo mdn_count(array('section' => 'section1'))
+ mdn_count(array('section' => 'section1'));
</txp:php>
Note: Although jmd_count shares some of the same features, it’s a little more flexible and efficient than mdn_count. For this example, it’d be:
<txp:php>
echo jmd_count(
array('table' => 'textpattern',
'where' => 'Section in("articles", "about")'
));
</txp:php>
Last edited by jm (2009-04-11 21:43:44)
Offline
Re: Show an article count for multiple sections
Brilliant — thanks, jm.
Mark
Offline