This may already exist, but I couldn’t find it. It outputs a pipe-delimited list of child categories of a particular parent category. I created it because I wanted an easy way to display only entries that are assigned to categories that are children of another category. I didn’t want to auto-assign the entries to the parent category (for one thing, I already had a bunch of entries in there that I would have had to go back and edit).
If you use this in the category parameter of your weblog:entries tag, you will also need to add parse=”inward” to weblog:entries.
Parameter: id - the id of the parent category to use.
Example:
{exp:weblog:entries weblog="news" category="{exp:vz_subcategories id="5"}" parse="inward"}For now, this only gets the immediate children. If you have a third level, they won’t be displayed. If anyone needs that functionality, let me know. It shouldn’t be too hard to add.
Changelog 1.0.2 - Changed the plugin name to “VZ Subcategories” so as not to conflict with the pre-existing Child Categories plugin. 1.0.3 - Respect the category sort order.
Hi,
You are unlucky: Subcategories plugin also exists already. You can find it here.
Hey, NKT,
Glad you figured out the first part of your question. To sort them, just add “ORDER BY cat_order” to the end of the query statement. So all together that line would be:
$results = $DB->query("SELECT cat_id FROM exp_categories WHERE group_id = '".$parent_id."' ORDER BY cat_order");I’m not sure if group listing function really fits into this plugin at this point, but I am going to update it to sort, which it really should have been doing all along. Thanks for the idea!
-Eli
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.