Is there a way to get this to list all categories (recursively) .. or does it just go one level down?
I’m looking for a solution to output a structure like this:
Category 1 - SubCat 1 - SubSubCat 1 - SubSubCat 2 - SubSubSubCat 1 Category 2 - SubCat 2 - SubSubCat 2 - SubSubCat 3
..etc.
Hi Bjorn,
The aim of this plugin to display child categories one level down, although by using this plugin together with some other plugin or EE tag it is possible to display additional levels of categories.
T o display all categories whatever deep they are in categories tree it seems best to use exp://weblog:category_archive tag.
Hi Ryan,
It seems to me that the easiest way to achieve it would be to to wrap the output of {child_category_start}{child_category_end} variable pair with the tags of Find and Replace Plus or Find and Replace plugin; plugin’s tag would have parameters regex=”yes” and find=”your_regex_string”.
Hi Ryan,
It seems that there is a simpler solution to your problem: you can use PHPStringFun plugin.
Using this plugin you can wrap the output of {child_category_start}{child_category_end} variable pair with its tags and use PHP rtrim function:
{exp:phpstringfun function="rtrim" par1=","}{child_category_start}{child_category_name},{child_category_end}{/exp:phpstringfun}
Absolutely nothing seems to be working for this. I’ve tried PHPStringFun, resorted to enabling PHP on the template and using PHP rtrim - I’m just always seeing the comma after the last item.
I’m looking inside the plugin to see how it is constructed to ee if I figure out why trying to do something with the resulting output isn’t working for me.
Hi Ryan,
For some reason the code as this does not work:
{exp:child_categories parent="179" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no" site="1" parse="inward" status="open|closed"}
{exp:phpstringfun function="rtrim" par1=","}{child_category_start} {child_category_name},{child_category_end}{/exp:phpstringfun}
{/exp:child_categories}
But the code as this works correctly:
{exp:phpstringfun function="rtrim" par1=","}{exp:child_categories parent="179" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no" site="1" parse="inward" status="open|closed"}{child_category_start} {child_category_name},{child_category_end}{/exp:child_categories}{/exp:phpstringfun}
Thank you for looking into that. I ended up getting this to work with some much simpler CSS (not IE6 friendly, but IE6 users should just see a spaced list of items with no commas, so no real harm there). Here is the CSS:
ul.subclass-list li:after { content:', '; }
ul.subclass-list li:last-child:after { display:inline; content:''; }
That puts a comma after every item in the list except the last one.
Hi Tim,
Since Child Categories plugin cannot output contents of custom category fields, you should use this plugin together with som other EE tag, such as exp:weblog:category_archive or exp:weblog:categories. If you use Child Categories plugin together with some of these tags, don’t forget to add
parse="inward"
parameter to exp:child_categories tag!
Unfortunately, these EE tags require parameter “weblog” to be defined.
If you can specify exactly one weblog, then your code could be somethind like this:
{child_category_start}
{exp:weblog:category_archive weblog="my_weblog" show="{child_category_id}" style="linear"}
{categories}
{if user_language=="nl"}
{child_category_name}
{if:else}
{child_category_name}_{user_language}
{/if}
{/categories}
{/exp:weblog:category_archive}
{child_category_end}
Hello,
I want Category name and Entries in a collapsible menu, There is no subcategories. For Example
Category 1 - Entry 1 - Entry 2 Category 2 - Entry 3 - Entry 4
My code using this plugin is as below.
{exp:weblog:categories category_group="3" weblog="weblog_name" dynamic="off" style="linear"} {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} {parent_category_name} {parent_category_end} {entries_start} {title} {entries_end} {/exp:child_categories} {/exp:weblog:categories}
It shows categories but does not show entries.
Do I forget to add something in code?
Thanks
Hi Asite,
Child Categories plugin does not display entries if there are no subcategories. To display entries posted into certain categories you should use exp://weblog:category_archive tag.
For this project I have categories, subcategories and products. I am displaying the categories on 1 template (index) and the subcategory on another template (list), and the products belonging to that subcategory on another template (prod-list) and a detailed description of the product on another template called (detail). All templates are in the same template group (products).
1 Weblog called “products” 1 Category Group assigned to Weblog “prodcuts” with following structure:
LEVEL1 Fruit LEVEL2 Apricot LEVEL2 Cherry LEVEL2 Citrus
LEVEL1 Vegetables LEVEL2 Beans LEVEL2 Beets LEVEL2 Carrots
I template group (products) with the following templates: index list product-list detail
I use 2 plugins: child categories and category id
The index template displays the 2 LEVEL1 categories: Fruit and Vegetables
{exp:weblog:categories weblog="products" parent_only="yes" style="linear"} <li class=”left-img left-img-2”>{category_image}{category_name}</li> {/exp:weblog:categories}
When I click on the fruit or vegetable link in the index template I link to “list” template and display the LEVEL2 sub-categories: Apricot, Cherry, Citrus. I am using the category ID plugin to call my category name from segment_4 and convert it into an ID for the category_id. This works fine.
{if segment_4!=""} {exp:category_id category_group="3" category_url_title="{segment_4}” parse=”inward”} {exp:child_categories parent="{category_id}” child_categories_sort_direction=”asc” show_empty=”yes” entries_sort_direction=”asc” parse=”inward”} {child_category_start} <li class=”left-img left-img-2”>{child_category_name}</li> {child_category_end} {/exp:child_categories} {/exp:category_id} {/if}
When I click on one of the sub-categories from the “list” template, I link to another template called “product-list” which should display all the products assigned to this sub-category. At this point I am stuck. I tried to pass the {parent_category_id} and {child_category_id} into the url and again grab it from the segment. However, this approach doesnt seem to work.
{if segment_3!=""} {exp:category_id category_group="3" category_url_title="{segment_3}” parse=”inward”} {exp:child_categories parent="{category_id}” child_categories_sort_direction=”asc” show_empty=”yes” entries_sort_direction=”asc” parse=”inward”} {child_category_start} <li class=”left-img left-img-2”>{child_category_name}</li> {child_category_end} {/exp:child_categories} {/exp:category_id} {/if}
My last step will be to display a detailed prodcut description. This will link to the “detail” template.
I am not sure if I am going about this the correct way. Is there a mistake in my code or should I structure/rethink my approach? I would appreciate some pointers.
thank you very much,
{if segment_4!=""} {exp:category_id category_group="3" category_url_title="{segment_4}” parse=”inward”} {exp:child_categories parent="{category_id}” child_categories_sort_direction=”asc” show_empty=”yes” entries_sort_direction=”asc” parse=”inward”} {child_category_start} <li class=”left-img left-img-2”>When I click on one of the sub-categories from the “list” template, I link to another template called “product-list” which should display all the products assigned to this sub-category. At this point I am stuck. I tried to pass the {parent_category_id} and {child_category_id} into the url and again grab it from the segment. However, this approach doesnt seem to work.{child_category_name}</li> {child_category_end} {/exp:child_categories} {/exp:category_id} {/if}
If I understood you correctly, you pass child_category_url_title from template “list” to template “prod-list” as the fourth url segment. Now, if you need child_category_id, use category_id plugin, as in template “list”:
{if segment_4!=""}
{exp:category_id category_group="3" category_url_title="{segment_4}" parse="inward"}
{category_id}
{/exp:category_id}
{/if}
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.