ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

New plugin: Category Sorted Entries

January 24, 2011 7:07pm

Subscribe [3]
  • #1 / Jan 24, 2011 7:07pm

    Michael Rog

    179 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"}
    {categories} {category_name} > {/categories}{entry_titles}{title}{/entry_titles}
    {/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>
    <p>{/categories}</p>
    
    <p>{entry_titles}<br />
    {title} ({entry_id})<br />
    {/entry_titles}</p>
    
    <p>{/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

  • #2 / Feb 15, 2011 11:38am

    E P Alton's avatar

    E P Alton

    55 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

  • #3 / Feb 15, 2011 11:52am

    Mark Bowen's avatar

    Mark Bowen

    12637 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

  • #4 / Feb 15, 2011 11:58am

    E P Alton's avatar

    E P Alton

    55 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.

  • #5 / Feb 15, 2011 12:35pm

    Michael Rog

    179 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.

  • #6 / Feb 15, 2011 4:56pm

    Mark Bowen's avatar

    Mark Bowen

    12637 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.)

    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

  • #7 / Feb 15, 2011 5:08pm

    Michael Rog

    179 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!

  • #8 / Feb 16, 2011 12:47pm

    E P Alton's avatar

    E P Alton

    55 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>
    <p>{/categories}</p>
    
    <p>{entry_titles}<br />
    {title}, {embed="maps/embed_02" entry_ids="{entry_id}"}<br />
    {/entry_titles}</p>
    
    <p>{/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

  • #9 / Feb 16, 2011 2:34pm

    Michael Rog

    179 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/

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases