Thanks for an incredibly useful plugin, it’s saved me quite a few headaches on a project I’m working on currently. One addition that would be very useful for me would be to make {entries_total} available within the {parent_category_start} and {parent_category_end} tags. Is that a particularly significant change to make? I’m going to have to start digging around the code soon either way, but it’d be great if you could point to a specific query that would need tweaking. I suspect I’m being overly optimistic here though.
Thanks again!
Hi,
You can easily display number of entries posted into parent category by using Child Categories plugin together with Entries Number plugin.
This is a great plugin - I need a bit of advise though I only want to output entries IF the current category has zero children {parent_category_children_count} - I just can’t seem to figure out the conditional, I tried php but the variable I set in {parent_category_start} didn’t seemed to hold outside of {parent_category_start} - so I’m obviously doing something wrong - and guidance would be appreciated..
{exp:child_categories parent="{segment_2}"}
{parent_category_start}
<h2>{parent_category_name}</h2>
<h3>number of children categories: {parent_category_children_count}</h3>
<hr >
{parent_category_end}
{child_category_start}
<h3>child: {child_category_name}</h3>
<h4>id: <a href="http://makebuild.com/index.php/products/{child_category_id}">{child_category_id}</a></h4>
<h4>children categories: {parent_category_children_count}</h4>
<h4>number of enteries: {entries_total}</h4>
{child_category_end}
/// I ONLY WANT TO OUT PUT THIS PART IF {parent_category_children_count} is ZERO
{entries_wrapper_top_start}<ul id="{child_category_id}" class="plist">{entries_wrapper_top_end}
{entries_start}
<li><a href="http://{site_url}/{site_index}/products/detail/{url_title}">{title}</a> Weblog: {weblog_name}, posted: {entry_date}</li>
{entries_end}
{entries_wrapper_bottom_start}</ul>{entries_wrapper_bottom_end}
/// END OF CONDITIONAL PART
{/exp:child_categories}
Hi, this looks like the plugin that can do what I want but even after reading pages and pages in this forum and experimenting for hours I cannot seem to get this working.
Basically I need the following to be outputted:
<ul id="countries">
<li class="country">
New Zealand
<ul id="cities">
<li class="city">
Auckland
<ul id="retailers">
<li class="retailer">The Shop Name</li>
<li class="retailer">Another Shop</li>
<li class="retailer">More Shops in Auckland</li>
</ul>
</li>
<li class="city">
Wellington
<ul id="retailers">
<li class="retailer">A shop in Wellington</li>
</ul>
</li>
</ul>
</li>
<li class="country">
Australia
<ul id="cities">
<li class="city">
Sydney
<ul id="retailers">
<li class="retailer">A Shop in Sydney</li>
<li class="retailer">Another one in Sydney</li>
</ul>
</li>
</ul>
</li>
</ul>
The categories are:
COUNTRY == PARENT_CATEGORY
CITY == CHILD OF PARENT_CATEGORY
RETAILER == ENTRY inside CHILD OF PARENT_CATEGORY
The code I am using at the moment doesn’t seem be able to nest the lists properly. And I am not sure how to get these things nest properly at all.
Here is the broken code:
<ul class="countries">
{exp:child_categories category_group="3" parse="inward" weblog="retailers" child_categories_sort_by="name" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="title" entries_sort_direction="asc" entries_limit="none"}
{parent_category_start}
<li class="country"><a href="#">{parent_category_name}</a></li>
{parent_category_end}
{child_category_start}
<li class="city"><a href="#">{child_category_name}</a></li>
{child_category_end}
{child_category_wrapper_top_start}<ul class="cities">{child_category_wrapper_top_end}
{child_category_wrapper_bottom_start}</ul>{child_category_wrapper_bottom_end}
{entries_start}
<li class="retailer"><a href="#">{title}</a></li>
{entries_end}
{entries_wrapper_top_start}<ul class="retailers">{entries_wrapper_top_end}
{entries_wrapper_bottom_start}</ul>{entries_wrapper_bottom_end}
{/exp:child_categories}
</ul>
This outputs:
<ul class="countries">
<li class="country"><a href="#">Australia</a></li>
<li class="city"><a href="#">Sydney</a></li>
<ul class="retailers">
<li class="retailer"><a href="#">Shop in Sydney</a></li>
</ul>
<li class="country"><a href="#">New Zealand</a></li>
<li class="city"><a href="#">Auckland</a></li>
<ul class="retailers">
<li class="retailer"><a href="#">Shop in Auckland</a></li>
<li class="retailer"><a href="#">Shop in Auckland 2</a></li>
</ul>
</ul>
None of these lists are nested properly and it seems the child_category_wrappers do not work.
Can anyone help me out please?
Thanks for reading, J.
PS: EE v1.6.8
I have a conditional that isn’t working inside a child_category_start/end variable pair as redundantly posted over on the single field plugin thread…
{exp:child_categories parent="62" parse="inward" child_categories_sort_direction="asc" entries_sort_by="date" entries_sort_direction="asc"}
{child_category_start}
<h2 id="{child_category_url_title}">
{if child_category_description}<abbr title="{child_category_description}">{child_category_name}</abbr>
{if:else}{child_category_name}{/if}
</h2>
{child_category_end}
I’ve tried {if child_category_description != ""} and reversing the logic with {if child_category_description == ""} but no joy.
Is it the parse=”inward” that’s affecting this or have I missed something else?
Hi,
Version 2.1 of Child Categories plugin released.
3 new parameters were added:
1) custom_field_name - Optional. Used when there is a need to display child categories with specific category custom field equal to (or not equal to) specific value.
2) custom_field_value - Optional. Used when there is a need to display child categories with specific category custom field equal to (or not equal to) specific value.
3) custom_field - Optional. Acceps the value “exclude”. Used when there is a need to display child categories with specific category custom field equal not equal to specific value.
EXAMPLES
To display only child categories with specific category custom field equal to (or not equal to) specific value, i.e. to show only entries with custom field “right_panel” set to “Yes”:
{exp:child_categories parent="{segment_3_category_id}" custom_field_name="right_panel" custom_field_value="Yes" child_categories_sort_by="custom" show_empty="yes" entries_limit="5" site="1" weblog="{aWeblog}" parse="inward"}
Or opposite tag, with custom field “right_panel” set to anything different then “Yes”.
{exp:child_categories parent="{segment_3_category_id}" custom_field="exclude" custom_field_name="right_panel" custom_field_value="Yes" child_categories_sort_by="custom" show_empty="yes" entries_limit="5" site="1" weblog="{aWeblog}" parse="inward"}
This functionality was developed by Baniaczek. Huge thanks for him!
I’m really close to getting this to do exactly what I need. However, I need to get LG Replace to work inside of this (or some other trick). I have this outputting everything right except I need to move one line outside of the {entries_start}{entries_end} loop so I thought LG Replace would do the trick, but I can’t get it working without breaking something else. If you remove the LG Replace code the conditional works perfectly, but I want what’s wrapped in the {exp:lg_replace:replacement needle="nms_chair"} tag to output where the {nms_chair} tag is.
{exp:child_categories parent="13|14" show_empty="no" weblog="faculty" parse="inward"
entries_sort_by="title" entries_sort_direction="asc"}
{exp:weblog:entries
dynamic="off"
orderby="f_last"
}{parent_category_start}
<h4 id="oc_{parent_category_url_title}" class="h_rule">{parent_category_name} Department</h4>
<div class="staffList">{parent_category_end}
{exp:lg_replace:haystack needles="nms_chair"}{nms_chair}
{child_category_start}
<h4>{child_category_name}</h4><div>{child_category_end}
{entries_wrapper_top_start}
<ul>
{entries_wrapper_top_end}
{entries_start}{exp:lg_replace:replacement needle="nms_chair"}
{if '{exp:single_field field="f_chair" entry_id="{entry_id}"}' != ''}
{exp:single_field field="f_first" entry_id="{entry_id}"} {exp:single_field field="f_last" entry_id="{entry_id}"}, <i>Chair</i>
{/if}{/exp:lg_replace:replacement}
{exp:field_value entry_id="{entry_id}"}<li>{field_value_f_first} {field_value_f_last}</li>{/exp:field_value}
{entries_end}
{entries_wrapper_bottom_start}</ul>{entries_wrapper_bottom_end}{/exp:lg_replace:haystack}{/exp:weblog:entries}
{/exp:child_categories}
Hi smartpill,
Your current code cannot work because Child Categories plugin does not output anything what is outside its variable pairs.
I suggest to use Field Value or Single Field plugin instead of exp:weblog:entries tag (you can easily wrap their tags around exp:child_categories tag) and to use Find and Replace Plus plugin instead of LG Replace. Find and Replace Plus supports {replace_area}{/replace_area} variable pair which allows finer control over parse order.
Hi smartpill, Your current code cannot work because Child Categories plugin does not output anything what is outside its variable pairs. I suggest to use Field Value or Single Field plugin instead of exp:weblog:entries tag (you can easily wrap their tags around exp:child_categories tag) and to use Find and Replace Plus plugin instead of LG Replace. Find and Replace Plus supports {replace_area}{/replace_area} variable pair which allows finer control over parse order.
I don’t see any example with Replace Plus on how to use it like LG Replace to move content. I see an example with Reeposition, but that doesn’t seem to work either. I managed to get the rest working with just Child Categories and Single Field, but I’m still stuck on moving that one line. Here’s what I have now:
{exp:child_categories parent="13|14" show_empty="no" weblog="faculty" parse="inward" entries_sort_by="title" entries_sort_direction="asc"}
{parent_category_start}
<h4 id="oc_{parent_category_url_title}" class="h_rule">{parent_category_name} Department</h4>
<div class="staffList">{parent_category_end}
{replace_area}{/replace_area}
{child_category_start}
<h4>{child_category_name}</h4><div>{child_category_end}
{entries_wrapper_top_start}
<ul>
{entries_wrapper_top_end}
{entries_start}{if '{exp:single_field field="f_chair" entry_id="{entry_id}"}' != ''}
{exp:replace_plus find='<p>{exp:single_field field="f_first" entry_id="{entry_id}"} {exp:single_field field="f_last" entry_id="{entry_id}"}, <i>Chair</i></p>'}{/exp:replace_plus}{/if}<li>{exp:edit_this:entry entry_id="{entry_id}" weblog_id="{weblog_id}" author_id="{author_id}" icon="edit_template"}{exp:single_field field='f_first' entry_id='{entry_id}'} {exp:single_field field='f_last' entry_id='{entry_id}'}</li>
{entries_end}
{entries_wrapper_bottom_start}</ul>{entries_wrapper_bottom_end}
{/exp:child_categories}
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.