EllisLab text mark
Advanced Search
     
New plugin: Category Sorted Entries
Posted: 24 January 2011 07:07 PM
Joined: 2007-05-30
178 posts

In response to this issue where I needed more specific control over the output of the Category Archive Tag, I hacked together a new plugin, Category Sorted Entries:

It’s behavior is basically the same as the standard Category Archive Tag, but it adds parameters to filter the output by entry ID, category, and category group.

An entry may belong to categories in several category groups, but I may not want to display the category listing of all of those groups at the same time. For example, if I were using categories to generate a breadcrumb, I would only want the categories from my Navigation category group to be displayed, so I might use the plugin like this:

{exp:category_sorted_entries channel="courses" style="linear" show_empty="no" group_id="1" entry_id="5"}
<p>{categories} {category_name} {/categories}{entry_titles}{title}{/entry_titles}</p>
{/exp:category_sorted_entries} 

Or, maybe I want to display a list of related entries (via Playa) organized in a nested list by category. In that case, it helps to filter by entry_id (and use Playa’s :entry_ids tag). Then a syntax like this would be helpful:

{exp:category_sorted_entries channel="test" style="nested" show_empty="no" entry_id="3|4|5|6"}

{categories}
<h3>{category_name} ({category_id})</h3>
{/categories}

{entry_titles}
<p>{title} ({entry_id})</p>
{/entry_titles}

{
/exp:category_sorted_entries} 

Or, perhaps I want to display entries listed by categories, but I don’t want the categories from a particular group (maybe an internal/private category scheme or navigation category group) to be displayed:

{exp:category_sorted_entries channel="test" style="nested" show_empty="no" group_id="not 4"

Or, perhaps I want to display all the entries with category 1 from group 1, but I want them to be displayed in the hierarchy of category group 3:

{exp:category_sorted_entries channel="test" style="nested" show_empty="no" category="1" group_id="3"

I welcome testing/feedback/critiques/suggestions, and I hope this plugin might be as useful for others as it is for me…

http://michaelrog.com/ee/category-sorted-entries

 
Posted: 15 February 2011 11:38 AM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2007-04-23
68 posts

Michael,

This looks promising for a project I’m working on, but I have one question: Within that {entry_titles} pair, is there any way to return additional fields? I need to pull in just slightly more than the title (one additional text field).

Thanks,
Ed

 
Posted: 15 February 2011 11:52 AM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

I may have missed it somewhere but was just wondering if this is for the 1.6.x branch of ExpressionEngine or 2.0?

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 15 February 2011 11:58 AM   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2007-04-23
68 posts

My question is about 2.0. I *think* the plugin was listed as EE2 compatible on Devotee but I’m not sure, come to think of it.

 
Posted: 15 February 2011 12:35 PM   [ # 4 ]   [ Rating: 0 ]
Joined: 2007-05-30
178 posts

Mark - This one’s for EE2. (While I’d be happy to see somebody port it back to EE1, such is not in the plans for me personally.)

E P Alton - I didn’t go so far as to enable the full range of channel data, yet. (I’ve considered doing so in the future, but that would drastically change the complexity of the plugin.) But, you can use the {entry_id} to return the necessary fields with the {exp:channel:entries} tag.

 
Posted: 15 February 2011 04:56 PM   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts
Michael Rog - 15 February 2011 05:35 PM

Mark - This one’s for EE2. (While I’d be happy to see somebody port it back to EE1, such is not in the plans for me personally.)

Ah thanks for that. Sorry meant to post back earlier to say that I’d found out it was for 2.0 when I downloaded it and took a look at it.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 15 February 2011 05:08 PM   [ # 6 ]   [ Rating: 0 ]
Joined: 2007-05-30
178 posts

I’ll also mention that for additional feature requests, support questions, etc., my GetSatisfaction page and the Devot:ee forum are open for business. Cheers, all!

 
Posted: 16 February 2011 12:47 PM   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2007-04-23
68 posts

Michael,

Just wanted to tell you that this plugin rocks! It helped me do something I’ve been struggling with for a while now so I can’t thank you enough.

Only question is that I’m not sure my method is very economical as far as queries go; it involves double nested templates. Reason being that I need to pull in more than just the entry_title of the items I’m listing. Maybe you can give me some advice?


Base template (the following is within an entries tag):

{embed="maps/embed_01" entry_ids="{sb_works_lit:entry_ids}"

First embedded template (embed_01):

{exp:category_sorted_entries channel="_works_lit" style="nested" show_empty="no" entry_id="{embed:entry_ids}"}

{categories}
<h3>{category_name} ({category_id})</h3>
{/categories}

{entry_titles}
<p>{title}{embed="maps/embed_02" entry_ids="{entry_id}"}</p>
{/entry_titles}

{
/exp:category_sorted_entries} 

Second embedded template (embed_02):

{exp:channel:entries weblog="_works_lit" disable="member_data|trackbacks|pagination" entry_id="{embed:entry_ids}" dynamic="off"}{work_title}
{
/exp:channel:entries} 


Thanks again for this great plugin!

Regards,
Ed

 
Posted: 16 February 2011 02:34 PM   [ # 8 ]   [ Rating: 0 ]
Joined: 2007-05-30
178 posts

Ed—Yes, the performance in your example will be atrocious. I have a few suggestions, but to be in keeping with the new EE Forum Policies, let’s jump over to Devot:ee for this one.

http://devot-ee.com/add-ons/support/category-sorted-entries/viewthread/693/