Category Posts Count

Download plugins, language packs and stuff.

Category Posts Count

Postby DarkSlim » Thu Nov 12, 2009 10:16 am

There was a request (by SolidSnake2003) on how to to show the category posts
count (not using the cn_category), and here is one plugin that I hope helps.

I have just created this simple plugin, it adds a new tag to your templates,
where you can specify a category and it reutrns and shows the number of
posts made in that category, the tag is {catposts|id} where id = the id of the
certain category we want to check, here is an example:

So if your category ID number 1 is "News", you can enter in your template:
Code: Select all
Category: News ({catposts|1})


And that's what you would see, 23 (for example) is the number of posts you
have in your 'News' category:
Code: Select all
Category: News (23)


Or, you can make it even smarter, but it would work only if the post have
only one category, {category} gets the name of the category and {category-id}
gets the id of the category (which does not show in templates info for some reason)
here is the example, it would looks the same:
Code: Select all
Category: {category} ({catposts|{category-id}})


That's is, hope it helps and if you have any questions or ideas how
to make it better/add stuff, I'll be glad to hear :)

* The plugin is attached to this post, it will be updated later if
there will be any other updates, just download the file, put
it in the plugins folder and activate it
Attachments
category-posts.rar
Category Posts Plugin!
(528 Bytes) Downloaded 96 times
User avatar
DarkSlim
 
Posts: 298
Joined: Thu Aug 06, 2009 4:18 pm
Location: IL

Postby D72 » Thu Nov 12, 2009 10:34 am

you're a guy full with surprises. :D
what a great job. will be come handy for me too.
Thanks man for the time and energy you've put in
User avatar
D72
 
Posts: 336
Joined: Thu Feb 22, 2007 12:05 am
Location: NL

Postby D72 » Fri Jan 15, 2010 4:27 pm

Hi Dark,
This is a nice plugin and useful in my case.
Allthough it's not working with multiple postcounts on one page.
In my template i have this html code:
Code: Select all
<p><font style="color:#999999">Categori?n</font> <a href="http://www.blabla.nl/showcase" class="tip" title="Projecten in Showcase: {catposts|4}">Showcase</a>   ›  <a href="http://www.blabla.nl/websites" class="tip" title="Projecten in Websites: {catposts|15}">Websites</a>   ›  <a href="http://www.blabla.nl/grafische-ontwerpen" class="tip" title="Projecten in Grafische ontwerpen: {catposts|25}">Grafische ontwerpen</a></p>

As you can see the Postcounts are called by Title.
But when i hover there is only one postcount which is coming thru, and in this case it's the first one, with postcount number 4. Number 15 and 24 does not apear.
Have a look at the site and hover on the Categories above the gallery. You will see what i mean. http://bit.ly/8NBz2P
I also have tried to place the postcounts not in a title syntax, but as regular text on the page, but this gives me also three same postcounts.
User avatar
D72
 
Posts: 336
Joined: Thu Feb 22, 2007 12:05 am
Location: NL

Postby DarkSlim » Sat Jan 16, 2010 4:21 pm

D72 wrote:Hi Dark,
This is a nice plugin and useful in my case.
Allthough it's not working with multiple postcounts on one page.
In my template i have this html code:
Code: Select all
<p><font style="color:#999999">Categori?n</font> <a href="http://www.blabla.nl/showcase" class="tip" title="Projecten in Showcase: {catposts|4}">Showcase</a>   ›  <a href="http://www.blabla.nl/websites" class="tip" title="Projecten in Websites: {catposts|15}">Websites</a>   ›  <a href="http://www.blabla.nl/grafische-ontwerpen" class="tip" title="Projecten in Grafische ontwerpen: {catposts|25}">Grafische ontwerpen</a></p>

As you can see the Postcounts are called by Title.
But when i hover there is only one postcount which is coming thru, and in this case it's the first one, with postcount number 4. Number 15 and 24 does not apear.
Have a look at the site and hover on the Categories above the gallery. You will see what i mean. http://bit.ly/8NBz2P
I also have tried to place the postcounts not in a title syntax, but as regular text on the page, but this gives me also three same postcounts.


Hmm I see, I really haven't tested it with more than one category
in your site it tells 40 posts for each category, is that right or just the first category has 40 posts?
Also I'll check the code for you :)
User avatar
DarkSlim
 
Posts: 298
Joined: Thu Aug 06, 2009 4:18 pm
Location: IL

Postby D72 » Sat Jan 16, 2010 5:01 pm

Showcase is a category, Websites and Graphic design are sub categories inside Showcase.
Showcase has a total of 40 entries. In Websites there are 37 entries en Graphic design there are 3 entries.
;) 37 + 3 = :) So Websites must show 37 postcounts and Graphic 3
But the first postcount is causing some kind of conflict while it only shows 40 postcounts
User avatar
D72
 
Posts: 336
Joined: Thu Feb 22, 2007 12:05 am
Location: NL

Postby DarkSlim » Sun Jan 17, 2010 12:32 pm

D72 wrote:Showcase is a category, Websites and Graphic design are sub categories inside Showcase.
Showcase has a total of 40 entries. In Websites there are 37 entries en Graphic design there are 3 entries.
;) 37 + 3 = :) So Websites must show 37 postcounts and Graphic 3
But the first postcount is causing some kind of conflict while it only shows 40 postcounts


Hmm it seems as it can be used once in a template (active, full etc')
I have tried some changes still couldn't make it work with multiple
I may try more when I'll have the time but you can try this for now:

Open plugins/category-posts.php

Find:
Code: Select all
function CategoryPosts($output)
{
global $row, $output;
   preg_match('/{catposts\|(\d+)}/i', $output, $tempp);
   return $output = preg_replace('/{catposts\|(\d+)}/i', count_category_entry($tempp[1]), $output);
}


After Add:
Code: Select all

function CategoryPostsTwo($output)
{
global $row, $output;
   preg_match('/{catpoststwo\|(\d+)}/i', $output, $tempp);
   return $output = preg_replace('/{catpoststwo\|(\d+)}/i', count_category_entry($tempp[1]), $output);
}

function CategoryPostsThree($output)
{
global $row, $output;
   preg_match('/{catpoststhree\|(\d+)}/i', $output, $tempp);
   return $output = preg_replace('/{catpoststhree\|(\d+)}/i', count_category_entry($tempp[1]), $output);
}


Just a fast try, it might help, now you have two more tags with the same effect
you can use for the two other categories like this:
{catpoststwo|id} - for the 2nd category
{catpoststhree|id} - for the 3rd category
User avatar
DarkSlim
 
Posts: 298
Joined: Thu Aug 06, 2009 4:18 pm
Location: IL


Return to Additional Downloads



Who is online

Users browsing this forum: No registered users and 0 guests

cron