Category Sorted Entries 2.3.0
Like the built-in EE Category Archive, but way mo' better (i.e. with tons more variables and parameters for added control).
Once upon a time, I wanted to select all my entries with a particular category from Category Group 1, but I wanted to display them in a nested list that included only categories from Category Group 2. I also needed to display the entry_id alongside the title of the entry. The standard Category Archive Tag was close, but didn't quite cut it; So, I wrote this plugin...
n.b. Category Sorted Entries uses the PHP array_fill_keys function, so PHP 5.2+ is required.
Examples: General Use
{exp:category_sorted_entries channel="test" style="nested" show_empty="no" group_id="2" category="not 2|3"}
{category}
<h3>{category_name} ({category_id})</h3>
{/category}
{entries}
<p>{title} ({entry_id})</p>
{/entries}
{/exp:category_sorted_entries}
{exp:category_sorted_entries channel="test" style="linear" show_empty="no" group_id="not 2" entry_id="1|2|3|4|5"}
{category}
<h3>{category_name} ({category_id})</h3>
{/category}
{entries}
<p>{title} ({entry_id})</p>
{/entries}
{/exp:category_sorted_entries}
If you are using additional plugins or modules inside the listing, you may need to use parse="inward" to ensure that entry IDs and other variables are available to those tags:
{exp:category_sorted_entries channel="test" style="nested" group_id="1" parse="inward"}
{category}
<h3>{category_name}</h3>
{/category}
{entries}
<p>{title}</p>
<p>
{exp:channel_ratings:rating entry_id="{entry_id}" scale="5"}
{rating:overall:stars}
{/exp:channel_ratings:rating}
</p>
{/entries}
{/exp:category_sorted_entries}
Parameters
All the parameters of the standard Category Archive Tag are available. In addition, some extra functionality is provided.
- entry_id - Entry IDs by which the results will be filtered. (Only entries matching this parameter will be displayed.)
- category - Category IDs by which the results will be filtered. (Only entries assigned to these categories will be displayed.)
- status - Status value(s) by which the results will be filtered. (Only entries with these status values will be displayed.)
- show_expired_entries - (default: "no")
- show_future_entries - (default: "no")
- group_id - The category group(s) by which entries will be sorted/displayed.
- show - IDs by which the category listing will be filtered. (Only these categories will be displayed.)
- show_empty - Whether categories with no entries are displayed. (default: "yes")
- parent_only - Show only categories with no parent. (i.e. "root" categories)
- container_tag - Enclosing tag for each category and its entries (when using "nested" style)
- container_class - Class attribute for each container (when using "nested" style)
- id - ID attribute for the root container (when using "nested" style)
- class - Class attribute for the root container (when using "nested" style)
- item_tag - Enclosing tag for each entry (when using "nested" style)
- item_class - Class attribute for each entry (when using "nested" style)
- backspace - Removes characters from the last iteration of the loop (when using "linear" style)
- disable - Skip processing of variables you don't need: category_fields, custom_fields, member_data
Note: The group_id, entry_id, category, and show parameters can accept multiple IDs, pipe-separated, and optionally can include a not trigger. (e.g. "1", "2|3|5", "not 2", and "not 3|4|6" are all valid.)
Variables
- Category variables are available within the {category} tag pair.
- Entry variables Member data are available within the {entries} tag pair.
| Entry Data | Member Data | Category Data |
|---|---|---|
Custom Channel Fields are also available using each field's short_name. |
|
Custom Category Fields are also available using each field's short_name. |