Hi Michel,
Try code as this:
{exp:child_categories parent="parent_cat_number" child_categories_sort_by="custom" show_empty="yes" parse="inward"}
{child_category_start}
<a href="/index.php/{exp:weblog:categories style="linear" weblog="my_weblog" show="{child_category_id}"}{sitemap_template}{/exp:weblog:categories}/c/{child_category_url_title}">{child_category_name}</a>
{if "{child_category_description}"}
{child_category_description}{/if}
{child_category_end}
{/exp:child_categories}
In order this code to work you should:
1) specify id number of parent category 2) specify weblog short name.
Good idea, but it returns an empty value for the custom category field.
/index.php//c/news
Would you have a little bug in your plugin?
Anyway, I was able to create my category listing without your plugin and with a bit of PHP. For those interested:
{exp:weblog:category_heading weblog="{my_weblog}" }
<?php $my_category_id = "{category_id}"; ?>
{/exp:weblog:category_heading}
<ul>
{exp:weblog:categories weblog="{my_weblog}" style="linear"}
{if parent_id == "<?php echo "$my_category_id"; ?>"}<li><a href="/index.php/{catpage_template}/c/{category_url_title}">{category_name}</a></li>{if:else}{/if}
{/exp:weblog:categories}
</ul>
Laisvunas, thank you for your plugin!
I’m hoping you are able to answer this for me…
I have a category structure like this:
Issue
- 2009-1 (entry id = 193)
- 2008-4
- 2008-3
- 2008-2
Section (entry id = 195)
- Editorial
- Lead article
- Article
Is it possible to limit the entries to only those who’s parent_id is 195 AND who also belong to the category_id 193?
I have tried experimenting with the code below, but I can’t get it to work.
{exp:child_categories weblog="target" parent="195" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" entries_sort_by="date" entries_sort_direction="asc" 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}
{if "{parent_category_id}" == "193"}
<li><a href="http://{weblog_url}{url_title}/">{title}</a> Weblog: {weblog_name}, posted: {entry_date}</li>
{/if}
{entries_end}
{entries_wrapper_bottom_start}</ul>{entries_wrapper_bottom_end}
{/exp:child_categories}
Thanks again
EDIT: I managed to get this working - but it’s obviously extremely slow due to the tag nesting:
{exp:child_categories weblog="target" parent="195" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" entries_sort_by="date" entries_sort_direction="asc" site="1" parse="inward"}
{child_category_start}
{exp:weblog:entries weblog="target" sort="asc" cache="yes" refresh="360" category="{child_category_id}" disable="category_fields|pagination|custom_fields|trackbacks|member_data"}
{categories show="{category_id}"}
<tr>
<td class="targetSection">{child_category_name}</td><td class="targetArticleTitle"><a href="http://{url_title_path=target/articles/}{segment_3}">{title}</a>{if {view_count_one} > '400'}<span class="popular">Popular</span>{/if}</td>
</tr>
{/categories}
{/exp:weblog:entries}
{child_category_end}
{/exp:child_categories}
Hi Adam,
If category 193 is subcategory of category 195, then you should use variable {child_category_id} instead of {parent_category_id}:
{exp:child_categories weblog="target" parent="195" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" entries_sort_by="date" entries_sort_direction="asc" 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}
{if "{child_category_id}" == "193"}
<li><a href="http://{weblog_url}{url_title}/">{title}</a> Weblog: {weblog_name}, posted: {entry_date}</li>
{/if}
{entries_end}
{entries_wrapper_bottom_start}</ul>{entries_wrapper_bottom_end}
{/exp:child_categories}
Sorry if this has been asked before, but can you use an if statement inside the results? This code doesn’t work like it should:
<pre><code>{exp:category_id category_group="6" category_url_title="{segment_1}” parse=”inward”}
{exp:child_categories parent="{category_id}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" entries_limit="1"}
{child_category_start}
<li{if segement_2 == child_category_url_title} class="active_nav"{/if}><a href="/{parent_category_url_title}/{child_category_url_title}/">{child_category_name}</a></li>
{child_category_end}
{/exp:child_categories}
{/exp:category_id}[/code]
That adds class=”active_nav” to every child, even though segement_2 and child_category_url_title only match for one of them.
Thanks for your help.
I noticed that after I posted it. I’m still having issues though - now it’s not set on any of them, even the correct one.
If I show what these vars are:
{segment_2} and {child_category_url_title} I can see where they are the same - on the correct category. But the if statement doesn’t seem to be evaluating to true at any time:
{child_category_start}
{segment_2}{child_category_url_title}
<li {if segment_2 == child_category_url_title} class="active_nav"{/if}><a href="/{parent_category_url_title}/{child_category_url_title}/">{child_category_name}</a></li>
{child_category_end}
What am I not seeing?
I just came across this example in this thread about conditionals:
{child_category_start}
<h2><a href="http://{homepage}/category/{child_category_url_title}/">{child_category_name}</a></h2>
{if "{child_category_description}"!=""}{child_category_description}{if:else}No description found{/if}
{child_category_end}
looks like you’d need to wrap your child_category_url_title in curly’s and quotes to get it to work.
-kev
Great work- thank you for your dedication to this community!
I would like to improve my current code block by moving the ul tags inside of my exp:child_categories statement. I thought I would be able to one of the wrapper pairs, but I couldn’t get it to work.
Here is what my code currently looks like.
<ul id="secondary-nav">
{exp:child_categories parent="4" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" }
{child_category_start}
<li><a href="http://{homepage}/category/{child_category_url_title}/">{child_category_name}</a></li>
{child_category_end}
{/exp:child_categories}
</ul>
I mean, it works now. But, it feels like the ul should be inside the exp:child_categories tags, no?
Thanks in advance!
Hi,
I released version 1.5.2 of Child Categories plugin.
In this release a bug was fixed - content of {entries_wrapper_bottom_start}{entries_wrapper_bottom_end} variable pair not being displayed in cases “entries_limit” parameter not defined and entries number being bigger than default value (10) of this parameter.
Everyone who uses this variable pair in his code is recommended to upgrade.
Hi,
I released version 1.6 of Child Categories plugin.
In this release two new variables were added:
1) {parent_category_count} - outputs count number, i.e. 1, 2, 3, etc., of the parent category.
2) {child_category_count} - outputs outputs count number, i.e. 1, 2, 3, etc., of the child category. Empty child categories are counted in case “show_empty” parameter has the value “yes”.
@ goodbytes It seems that you need to use EntryData plugin together with Child Categories plugin. Using these plugins together you should add parse=”inward” parameter to {exp:child_categories} tag. Try this code:It should work if you will not make some mistake while coding this.{exp:child_categories parse="inward" all_other_parameters="........."} {entries_start} {exp:entrydata:field field="menu_picture" weblog="{weblog_short_name}" url_title="{url_title}"} {exp:entrydata:field field="menu_description" weblog="{weblog_short_name}" url_title="{url_title}"} {exp:entrydata:field field="menu_price" weblog="{weblog_short_name}" url_title="{url_title}"} {entries_end} {exp:child_categories}
I am looking for this solution as well (custom weblog fields) but I couldn’t seem to find anything about the EntryData plugin. When I click that link it gives me an error page and Google didn’t help much. Any suggestions?
I love this plugin. It saves me from using the Query module as much. It’s a nicer and cleaner approach. Thanks for all the hard time put in to making this available!
Hi ciscoospina,
EntryData plugin is no more available because its author put down the site.
Instead of EntryData plugin use Single Field plugin.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.