I’ve got two parent category groups, and I’m trying to re-create this bit of code to show the one (or more) categories that have been selected for an entry:
{categories backspace="1" show="not 17|18|19|20|21|22|77|78|79|80|81|82|83|84|85"}{category_name}, {/categories}
with the child categories plugin:
{exp:child_categories parent="17"}
{child_category_start}{child_category_name}, {child_category_end}
{/exp:child_categories}
But instead of just getting one category out, I get all the child categories shown. Have I got the wrong end of the stick somewhere?
Thanks,
A quick suggestion (unless there’s another way round it):
{child_category_children_count}
I want to list out all child categories from a given parent, but I want to make the child categories a link only if they have child categories themselves…
Hi Steve,
Child categories plugin is meant only to output categories 1 level deep, i.e. parent categories and their children, not childrens’ children.
If you want to display categories more than 1 level deep you might find the plugin Recursive Subcategories useful.
Hi - thanks for a quick response.
Understood re: displaying more than one level, however I’m actually only wanting to display parent and child, the problem is I want to make the child clickable ONLY if it has children itself (I don’t want to actually display the child’s children).
I’ll try the recursive subcategories plugin, but I found your one perfect (since I can display entries too with the same code).
Thanks! Steve.
Hi Luc, Your code should be as this:{exp:child_categories parent="17"} {child_category_start} {if "{child_category_id}" != "17" AND "{child_category_id}" != "18" AND "{child_category_id}" != "19"} {child_category_name}, {/if} {child_category_end} {/exp:child_categories}
Hi, That just outputted the same as I had - every child category, regardless of it being selected. I should have probably said that category_id 17 and 18 are the parents, all the rest are children.
Hi Luc,
That just outputted the same as I had - every child category, regardless of it being selected. I should have probably said that category_id 17 and 18 are the parents, all the rest are children.
I don’t understand which one category you want to output. How do you distinguish selected category from others? And what do you mean by “selected category”?
What I mean, and what I get from my code (although I have to manually enter category IDs when they’re added to, hence the use of this plugin), is a list of child categories that have been selected for that particular entry. For example, I have categories set up like
17 - Parent 1 —- Child 1 —- Child 2 —- Child 3
18 - Parent 2 —- Child 4 —- Child 5 —- Child 6
Selecting “Child 2” in the publish/edit screen should then only output “Child 2” in my template.
Hope that’s clearer…
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.