Content last modified Tuesday 21 June 2016
hop to #bottom
Categories:
Author:
Current version:
0.9
About It:
Get it:
Rate it:
  • Helpful?
  • 7 Yes
  • 6 No
Flag it:
Contact Reason [ ? ]

cbs_category_list

Description

This simple plugin is basically equivalent to category_list, excepted that it is section-sensitive and only lists article categories.

Categories are displayed using their title and optionally their article count for the selected section and sorted alphabetically by title.

If no article is found in the section for a category, this category will not be shown.

Syntax

<txp:cbs_category_list />

Attributes

Required

none.

Optional

  • section: The section to display the related article categories. When ‘default’ (the frontpage) is specified, it shows all categories related to sections which are part of the frontpage. Default is the current section.
  • sticky: When set to true, will display the category list of ‘sticky’ articles instead of ‘live’ articles. Default is false.
  • posted: Either ‘past’, ‘future’ or ‘all’. Will only count articles with the specified publication date. ‘all’ is slightly faster because MySQL will be able to cache the query. Default is ‘past’.
  • parent: The parent category name. If specified, will return only the direct children categories for this parent. It will not show children of children. Default is any category.
  • showcount: When set to true, displays the number of related articles next to each category. Default is false.
  • label: Label for the top of the list. Default is no label.
  • labeltag: Independent wraptag for label for the top of the list. Default is empty.
  • break: HTML tag to be used for line breaks, without brackets. Default is br.
  • wraptag: HTML tag to be used as the wraptag, without brackets. Default is empty.
  • class: CSS class attribute for wraptag, default is cbs_category_list.
  • activeclass: CSS class attribute for the currently active category, if any. By default, the active category is displayed like the other ones.

Important

This plugin only works with Textpattern 4.0.2 and above. Please upgrade if required.

Changes history

v0.9 (2006-09-27)

  • Code cleaning.

v0.8 (2006-09-16)

  • Added the sticky attribute to display sticky articles categories instead of published articles categories.

v0.7 (2006-07-27)

  • Small bugfix: using br instead of <br /> as a default value for “break”.

v0.6 (2006-06-28)

  • Small bugfix: no more PHP warning if the list is empty.

v0.5 (2005-11-21)

  • Added the labeltag attribute to conform with the new label behavior of Textpattern 4.0.2.

v0.4 (2005-10-13)

  • Added the activeclass attribute to display the active category differently.

v0.3 (2005-10-05)

  • Article count is now optional and disabled by default.
  • Tweaked code.

v0.2 (2005-10-01)

  • Only counts articles having the status set to ‘Live’.
  • Compatible with table prefixes.

v0.1 (2005-09-15)

Initial release.

Article Request Count:
Initially released:
2005-09-15
Posted here:
15 Sep 2005
Article modified:
20 Apr 2015

You may want to leave your comments/questions at the Forum thread for quicker feedback. Otherwise, comment away:

Commenting is closed for this article.

Commented (24)

Lucas Haley:
This caused my site to not render. Might be a conflict somewhere?

Fatal error: Call to undefined function pagelinkurl() in textpattern/lib/txplib_misc.php(429) : eval()’d code on line 50
Thanks for your feedback, well I just noticed that I use a brand new function that appeared with version 4.0.1. So this plugin works with Textpattern 4.0.1 and above only. Please upgrade if required.
Lucas:
That’s it. I thought I had upgraded, apparently I did not. Thanks!
Hi, i can not install the plugin on the german TXP Blog which is running on TXP v. 4.0.1. After inserting the code and hitting the okay button i am directed to the index page of textpattern directory. Usually i do not have any problems installing plugins except for this one and mem_online_users. Both fail the same way.
alex:
okay, i could install the plugin on a testinstall of TXP 4.0.1 .. so my problem must have to do with probably some other plugin… *sigh
Christophe Beyls:
Yep, I would say the same. Glad you find it useful. I just like small and fast code; if you look at the source you’ll see it’s clean and doesn’t do anything special so I don’t think it causes any bug like that.
lr:
Nice job. Only caveat is that when an article is published, then set to pending (etc.) or deleted, the count remains the same.
Alexander:
This plugin doesn’t work in case of using table prefix.
Both issues fixed in new version 0.2.
Jonathan:
Nice plugin does the job very well. Can we have an option to remove the number of articles associated with a category?
warren:
it would be nice if you could turn off the article count—I had to hack it out. nice plugin!
Jonathan:
Hi Warren! Christophe has not answered if he is going to add this feature of turning off the count. I can’t find another plugin that does what this one does, but I need it without the count! How did you hack the plugin?
Jonathan:
Also, does not seem to be a forum post in Plugins yet. Christophe, can you start a new post so we can discuss your plugin?
I just created a topic on the Textpattern support forum, you’re welcome to continue our little discussion there ;)
Thanks, great small plugin. With clean urls perfect for txp-standard.
I needed this desperately and it works fine. Thanks a lot.
Thanks so much! This is so much easier than hardcoding my categories!
Great plugin! I was wondering if there is a way to hack this so I can have the pagecount also linked along with the category- inside the same tag. Any ideas? thanks
Andrew:
Hi there.
This is looking really useful for me…thanks!..except that is there any way to sort by any means other than alpha?
Currently it is not possible to change the sort order through the options, however you can change it easily in the plugin code if you know a bit of SQL. How do you want to sort the entries? I could consider adding the option.
Jeff Gill:
This is very good! Is there any way this could also work as a popup list?
Andy:
Would be even better (for me anyway ;o) if you could define the sort order by a custom field. Great plugin

The article count for each category is just what I needed. Thanks!

Nick:

Hi, it doesn’t work with the mlp-pack..when switching the language it shows only the standard title..

Subscribe to this article's comments RSS feed. [ ? ]   View Recent Comments across the site.

Would you care to write a comment or visit the forum discussion?

You know you want to visit the Archives.

Browse

Categories


Articles

There are also tag clouds, 'cause those are fun.