The attached add-on files may be out of date. Please visit Devot-ee for the latest versions.
Displays subcategories.
PARAMETERS (All optional):
1) parent - parent category id. Pipe is supported e.g. parent=”3|16|28”. 2) sibling - child category id (plugin will find parent). 3) category_group - category group id or name (highest level categories of that category group will be treated by plugin as parent categories). Either “parent” or “sibling” or “category_group” MUST BE defined. 4) weblog - weblog name. Pipe and “not” supported. 5) site 6) parent_categories_sort_by - for use with “category_group” parameter. Values: “name”, “id” and “custom”. 7) parent_categories_sort_direction - used with “category_group” parameter. Accepts values “asc” and “desc”. Default “asc”. 8) child_categories_sort_by - values: “name”, “id” and “custom” (children will be sorted using custom order as defined in control panel). Default “name”. 9) child_categories_sort_direction - values: “asc” and “desc”. Default is “asc”. 10) show_empty - specify if child categories having no entries should be displayed. Accepts values “yes” and “no”. Default “no”. 11) entries_sort_by - values: “title” and “date”. Default “date”. 12) entries_sort_direction - values: “asc” and “desc”. Default is “desc”. 13) entries_limit - how many entries posted into child category should be displayed. Accepts as its value an integer or “none”. Default is “10”. Value “none” means that all entries will be displayed. 14) date_format - PHP date format string (Not ExpressionEngine’s date format string!). Default is “Y-m-d”. 15) show_expired - values: “yes” and “no”. Default “yes”. 16) status - status of entries. “not” and pipe supported. 17) invalid_input - If the value is “alert”, then in cases when some parameter’s value is invalid plugin exits and PHP alert is being shown; if the value is “silence”, then such in cases plugin finishes its work without any alert being shown. Default is “silence”. 18) custom_field_name - used with “custom_field_value” parameter to display child categories with specific category custom field equal, not equal or like to specific value. 19) custom_field_value 20) custom_field - values: “include”, “exclude”, “like”. Used to display child categories with specific category custom field equal not equal or like to specific value. Default is “include”.
VARIABLE PAIRS:
1) {parent_category_start}{parent_category_end} - wraps code which will be iterated for each parent. Single vars:
{parent_category_id}
{parent_category_name}
{parent_category_url_title}
{parent_category_description}
{parent_category_image}
{parent_category_children_count}
{parent_category_count}
{parent_category_total}
2) {child_category_start}{child_category_end} - wraps code which will be iterated for each child. Single vars:
{parent_category_id}
{parent_category_name}
{parent_category_url_title}
{parent_category_description}
{parent_category_image}
{parent_category_children_count}
{parent_category_count}
{parent_category_total}
{child_category_id}
{child_category_name}
{child_category_url_title}
{child_category_description}
{child_category_image}
{child_category_order_num} - outputs number used for custom ordering of categories.
{child_category_count}
{entries_total}
3) {entries_start}{entries_end} - wraps code which will be iterated for each entry posted into child category. Single vars:
{parent_category_id}
{parent_category_name}
{parent_category_url_title}
{parent_category_description}
{parent_category_image}
{parent_category_children_count}
{parent_category_count}
{parent_category_total}
{child_category_id}
{child_category_name}
{child_category_url_title}
{child_category_description}
{child_category_image}
{child_category_order_num}
{child_category_count}
{entries_total}
{weblog_name}
{weblog_short_name}
{weblog_url}
{title}
{url_title}
{entry_date}
{entry_id}
{count}
4) {entries_wrapper_top_start}{entries_wrapper_top_end} - top part of the code with which you may want to wrap output of {entries_start}{entries_end} variable pair. Single vars:
{entries_total}
{child_category_id}
5) {entries_wrapper_bottom_start}{entries_wrapper_bottom_end} - bottom part of the code with which you may want to wrap output of {entries_start}{entries_end} variable pair. Single vars:
{entries_total}
{child_category_id}
6) {child_wrapper_bottom_start}{child_wrapper_bottom_end} - bottom part of the code with which you may want to wrap all data of child category. Single vars:
{entries_total}
{child_category_id}
7) {parent_wrapper_bottom_start}{parent_wrapper_bottom_end} - bottom part of the code with which you may want to wrap all data of parent category. Single vars:
{parent_category_children_count}
{parent_category_id}
The tag {exp:child_categories} MUST contain at least one variable pair out of {parent_category_start}{parent_category_end}, {child_category_start}{child_category_end} and {entries_start}{entries_end} variable pairs and each single variable MUST BE inside relevant variable pair.
EXAMPLE OF USAGE:
{exp:child_categories parent="18|29" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" entries_sort_by="date" entries_sort_direction="asc" entries_limit="3" site="1"}
{parent_category_start}
<h1><a href="http://{homepage}/category/{parent_category_url_title}/">{parent_category_name}</a></h1>
{parent_category_end}
{child_category_start}
<h2><a href="http://{homepage}/category/{child_category_url_title}/">{child_category_name}</a></h2>
Total entries: {entries_total}
{child_category_end}
{entries_wrapper_top_start}<ul>{entries_wrapper_top_end}
{entries_start}
<li><a href="http://{weblog_url}{url_title}/">{title}</a> Weblog: {weblog_name}, posted: {entry_date}</li>
{entries_end}
{entries_wrapper_bottom_start}</ul>{entries_wrapper_bottom_end}
{/exp:child_categories}
Great ! Thank you. Its working great. Just have two questions:
Great work! Tank you
Hi,
I have 2 weblogs using the same category_group and want to display entries only from 1 weblog….is this possible to define weblog?
Currently it is not possible, but it seems that to add “weblog” parameter should not be complicated. I will consider this suggestion when releasing a new version.
Is this possible to display all categories and subcategories without defining parent=”18|29” but defining category_group_id so it would display all categories and subcategories within its category_group? That would work great as after adding a new category it will work without adding category_id to parent parameter
Have you considered exp:weblog:categories tag? This tag has “category_group” parameter and “style” parameter which accepts value “nested”. It seems that exp:weblog:categories tag can display all categories and subcategories within its category_group - exactly as you want.
Hi Thank you, Im now using exp:weblog:categories tag but im not getting exacly the results I want. I need to display all categories and subcategories within categories and as well titles of entries from these subcategories
So my code looks like this
{exp:weblog:categories category_group="2" weblog="server_product" }
<li><a href="http://{site_url}index.php/servers/category/C{category_id}">{category_name}</a>
{exp:weblog:entries weblog="server_product" category_id="{category_id}"}
{title}
{/exp:weblog:entries}
</li>
{/exp:weblog:categories}
Its displaying properly all categories and subcategories, but its displaying all entries under every category and subcategory….like:
cat1
entry1
entry2
entry3
sub1
entry1
entry2
entry3
sub2
entry1
entry2
entry3
cat2
entry1
entry2
entry3
sub21
entry1
entry2
entry3
sub22
entry1
entry2
entry3
where its should be:
cat1
sub1
entry1
entry2
cat2
sub21
entry3
Do you have maybe idea how to fix it? Thank you
Hi combinedmedia,
Try the following code:
{exp:weblog:categories category_group="2" weblog="server_product"}
{exp:child_categories parent="{category_id}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="date" entries_sort_direction="asc" entries_limit="5" site="1"}
{parent_category_start}
<a href="http://{site_url}index.php/servers/category/C{parent_category_id}">{parent_category_name}</a>
{parent_category_end}
{child_category_start}
<a href="http://{site_url}index.php/servers/category/C{child_category_id}">{child_category_name}</a>
{child_category_end}
{entries_start}
<a href="http://{site_url}index.php/servers/category/C{child_category_id}/{url_title}/">{title}</a>
{entries_end}
{/exp:child_categories}
{/exp:weblog:categories}
Not sure it will work, but it seems worth to try.
Hi Thank you, its working but unfortunatelly it still displays entries from 2 weblogs, like there is no parametr weblog. I was trying a lot of combinations and nothing is working. I will probably create a new category group and connect them to my weblog, so it will display properly. Thank you very much for help!
Just updated the plugin to version 1.1.
In version 1.1 two new things are added:
1) parameter “weblog”: it allows you to specify weblog name. You can use the pipe character to get entries from any of those weblogs, e.g. weblog=”weblog1|weblog2|weblog3”. Or you can add the word “not” (with a space after it) to exclude weblogs, e.g. weblog=”not weblog1|weblog2|weblog3”;
2) variable {weblog_short_name}: it outputs short name of the weblog. If you wish to output full name, use variable {weblog_name}.
If you use parameter “weblog”, then the search will go only through the specified weblogs. That means that the output of {entries_total} variable will be accordingly affected: entries which are posted into weblogs not included by “weblog” parameter will not be counted.
Laisvunas following my last post this is what I need to achive, the problem is if the client adds a catagory the we’ll need to amend this code as the IDs are hard coded so it aint great:
{exp:query sql = ” SELECT cat_id AS child_category_id,
cat_name AS child_category_name,
cat_url_title AS child_category_url_title,
cat_description AS child_category_description,
cat_image AS child_cat_image,
cat_order AS child_cat_order
FROM exp_categories WHERE parent_id = ‘11’ ORDER BY cat_order”}
child Name: {child_category_name} child Title: {child_category_url_title} child Image: {child_cat_image} child Description: {child_category_description}
{/exp:query}
If anyone has a better idea how to achieve this please let us know, the worknig example can be seen here http://probel.previewurl.net/ click on the left nav to get a pop up whic will display child catagories.
Good work!
My only question is: can I use custom fields in the outputted results?
Right now it’s outputting {title}, but I’d like to include some of my weblog custom fields in the results. Once I get that up and running, my goal of this week has been completed 😊
thanks already for this great plugin!
UPDATE:
I managed to get really close to my goal, with following code:
{exp:child_categories parent="6" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" entries_sort_by="date" entries_sort_direction="asc"}
{parent_category_start}
{parent_category_end}
{child_category_start}
<h2>{child_category_name}</h2>
{exp:weblog:entries weblog="menuinbeeld" dynamic="off" category="9"}
<div class="menuitem">
<div class="menutitle">{title}</div>
<div class="menupicture">{menu_picture}</div>
<div class="menudesc">{menu_description}</div>
<div class="menuprice">{menu_price} €</div>
</div>
{/exp:weblog:entries}
{child_category_end}
{entries_start}
{entries_end}
{/exp:child_categories}
Now you can see I hard-coded the category to “9”. This however, should be dynamically changed to {child_category_id} but just replacing the “9” with {child_category_id} does not work.
I also tried php but it didn’t work. Does anyone have an idea on how to solve this, I bet this will be useful for many people out there trying to do the same thing.
UPDATE2:
the following looks logic, but doesn’t work either :(
{child_category_start}
<h2>{child_category_name}</h2>
{assign_variable:jorre="{child_category_id}"}
{exp:weblog:entries weblog="menuinbeeld" dynamic="off" category="{jorre}"}
<div class="menuitem">
<div class="menutitle">{title}</div>
<div class="menupicture">{menu_picture}</div>
<div class="menudesc">{menu_description}</div>
<div class="menuprice">{menu_price} €</div>
</div>
{/exp:weblog:entries}
{child_category_end}
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.