Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-02-19 23:12:26

lister
Member
Registered: 2008-02-13
Posts: 76

A list of catagories with a number of articles assigned to display?

Hi everyone, I was wondering how you go about listing the categories down a sidebar and show the value of how many articles have been assigned to that category? I am looking at <txp:category_list />
and <txp:if_category name> but I’m a little unsure how to implement this further to show the article amounts and then once clicked show only the articles assigned to that category..??

could anyone help, or point me in the right direction..

Thanks

lister

Offline

#2 2009-02-20 01:22:01

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: A list of catagories with a number of articles assigned to display?

There is cbs_category_list but it is context-sensitive so it will only display categories used in the current section being viewed. Don’t know if that is too restrictive for you.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#3 2009-02-20 17:50:45

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

Re: A list of catagories with a number of articles assigned to display?

Using mdn_count you could do something like this:

<txp:category_list wraptag="ul" break="li">
     <txp:category title="1" link="1" /> (<txp:mdn_count category='<txp:category />' /> articles)
</txp:category_list>

Offline

#4 2009-02-20 23:52:48

lister
Member
Registered: 2008-02-13
Posts: 76

Re: A list of catagories with a number of articles assigned to display?

Thanks a lot for this nice one.. just a quick question. I have added the list to the sidebar which shows all through the site. The Articles I create only get assigned to the blog section (most recent article will show on the front page). I have implemented this code

<txp:category_list wraptag="ul" break="li">
<txp:category title="1" link="1" section="blog" /> 
(<txp:mdn_count category='<txp:category />' /> articles)</txp:category_list> 

I have added the section=“blog”.. as before when I clicked the category list on the home page the URL was wrong and took me to category page. Now it takes me to the blog section with the articles showing of that category.

How can I hide categories created but with no posts not too show up in the list?

Thanks for the help so far..

lister

Offline

#5 2009-02-21 00:52:54

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

Re: A list of catagories with a number of articles assigned to display?

lister wrote:

How can I hide categories created but with no posts not too show up in the list?

TXP Tip :)

Offline

#6 2009-02-21 10:43:08

lister
Member
Registered: 2008-02-13
Posts: 76

Re: A list of catagories with a number of articles assigned to display?

Nice one Els really appreciate the help

Last edited by lister (2009-02-21 10:44:54)

Offline

Board footer

Powered by FluxBB