Plugin: VZ Subcategories
Posted: 16 September 2009 07:42 PM   [ Ignore ]  
Grad Student
Rank
Total Posts:  35
Joined  02-11-2008

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.

File Attachments
pi.vz_subcategories.php.zip  (File Size: 2KB - Downloads: 136)
 Signature 

Eli Van Zoeren
http://elivz.com

Profile
 
 
Posted: 19 September 2009 02:20 PM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1156
Joined  02-02-2007

Hi,

You are unlucky: Subcategories plugin also exists already. You can find it here.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

Profile
 
 
Posted: 20 September 2009 05:28 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  35
Joined  02-11-2008

Damn, I even searched and that one didn’t come up for some reason. I’m going with “VZ Subcategories”. Namespacing FTW.

 Signature 

Eli Van Zoeren
http://elivz.com

Profile
 
 
Posted: 04 February 2010 06:24 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
RankRank
Total Posts:  198
Joined  06-06-2007

Would it be possible to just set a category group id and get a list of all the top level categories. Sorted by their custom sort method.

Profile
 
 
Posted: 04 February 2010 06:32 AM   [ Ignore ]   [ # 4 ]  
Lab Assistant
RankRank
Total Posts:  198
Joined  06-06-2007

Ok i’ve modded the plugin to do what i want by changing parent_id to group_id. Yay! I’m a PHP newb, does anyone know how i would sort the results by their category order?

Profile
 
 
Posted: 05 February 2010 12:45 AM   [ Ignore ]   [ # 5 ]  
Grad Student
Rank
Total Posts:  35
Joined  02-11-2008

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

 Signature 

Eli Van Zoeren
http://elivz.com

Profile
 
 
Posted: 08 July 2010 04:49 AM   [ Ignore ]   [ # 6 ]  
Lab Assistant
RankRank
Total Posts:  119
Joined  04-04-2004

Hi Eli,
found this cool plugin while searching for a solution. But I have EE2 :-(
Do you have plans, to update this plugin for EE2?

Cheers
awa

Profile
 
 
Posted: 09 July 2010 08:10 AM   [ Ignore ]   [ # 7 ]  
Grad Student
Rank
Total Posts:  35
Joined  02-11-2008

I would love to port it to EE2, but I’m not likely to have time in the next few months. If someone else wants to go for it, you have my blessing. Otherwise, I’ll get to it as soon as I can.

 Signature 

Eli Van Zoeren
http://elivz.com

Profile
 
 
Posted: 09 July 2010 09:45 AM   [ Ignore ]   [ # 8 ]  
Lab Assistant
RankRank
Total Posts:  119
Joined  04-04-2004

Too bad,
but thanks for the reply. wink
awa

Profile
 
 
   
 
 
‹‹ Date Maths      Plugin: In Segments ››