We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

New plugin: exp_catcount (myFirstPlugin)

Development and Programming

GDmac - expocom's avatar
GDmac - expocom
350 posts
16 years ago
GDmac - expocom's avatar GDmac - expocom

My first plugin is a simple one. It’s to count posts in a category. Previously (forum thread) i used to insert query module stuff, now just use {exp:exp_catcount cat_id='x'}

{exp:weblog:categories weblog="news"}
{category_name} : {exp:exp_catcount cat_id="{category_id}" status="closed"} posts

{/exp:weblog:categories}

Hope this comes in handy for some of you.

usage

{exp:exp_catcount cat_id="x" [weblog_id="x"] [status="x"] }

returns:

number of posts in a category [from weblog, with particular status].

parameters: cat_id : cat_id of the category (mandatory) weblog_id : (optional) limit to weblog (otherwise counts posts of all weblogs using the same category group) status : (optional) limit to post with status=…

(otherwise : default = open)

edit: Description updated edit: Todo: weblog_id=2|4|7 and status=open|draft|new

       
Justin Long's avatar
Justin Long
196 posts
16 years ago
Justin Long's avatar Justin Long

Great looking plugin will save me from write custom querys for this

       
ender's avatar
ender
1,644 posts
16 years ago
ender's avatar ender

would recommend not using this in a terribly large loop of categories as it will execute a new query every time through.

       
Todd Levy's avatar
Todd Levy
20 posts
16 years ago
Todd Levy's avatar Todd Levy

Does this ignore future dated posts in the category count?

See here for my example… http://ellislab.com/forums/viewthread/53346/P18/#407733

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

To count posts in a category you can use the plugin Entries number

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.