That is correct. From template “list”, I pass {parent_category_url_title} as segment 3 and {chilc_category_url_title} as segment 4 to the templatel “prod-list”.
I updated the code for the “prod-list” template today and made some progress. In my previous code, I forgot to include the {entries} tag which is needed to display the entires for the subcategory. here is the current code:
{exp:category_id category_group="3" category_url_title="{segment_4}" parse="inward" }
{exp:child_categories weblog="products" parent="{category_id}" parse="inward" }
{entries_start}
<li class="left-img left-img-2"><a href="http://{path=products/details}">{product_thumbnail}{title}</a></li>
{entries_end}
{/exp:child_categories}
{/exp:category_id}
The problem that I am having is that the entries dont display correctly. My theory is that it may not be possible to take segment 4 (which is child category url title) and use that as the {category-id} for the parent tag on the prod-list template?
the url structure on list is: http://www.site.com/index.php/products/list/category/fruit/
the url structure on prod-list is: http://www.site.com/index.php/products/prod-list/fruit/apricot/
when I try to use segment4 as my category_id, nothing displays. when I try to use segment3 all entries display from all subcategories, which makes sense because segment3 would be the main parent category. Is there a solution?
1.) this is correct. Fruit is the level 1 category which holds a few subcategory, including: 2.) apricot is one of the level 2 categories. 3.) there are some weblog entries in the category apricot. 4.) I am not sure if I have to display them using the url http://www.site.com/index.php/products/prod-list/fruit/apricot/ This was the best solution that I was able to come up with that would let me display the entries of a certain category on the “prod-list” template. I passed the parent_category_url_title and child_category_url_title to the “prod-list” template when I link from the “list” template to a subcategory.
on my “list” template, segment3, fruit gets displayed because I link to it with the category tag. So I think ee automatically puts segment2 “category”, and segment3 “fruit” in the url. When I link from “list” to “prod-list” template, I am passing parent_category_url_title which is segment3 or fruit, and I pass child_category_url_title which is segment4 or apricot. The reason I try it this way was because I thought that I needed to have that info in the url on the “prod-list” template so that I could read the category_id number and then display the entries for sub category apricot. Is this approach where the problem is? So the reason is not for pretty url or anything, I am just trying to get it to work.
Hi Florian,
If you do not need to output any info about level 1 category, then you can simply use exp:weblog:entries tag; there is no need to use Child Categories plugin:
{exp:category_id category_group="3" category_url_title="{segment_4}" parse="inward" }
{exp:weblog:entries weblog="products" category="{category_id}"}
<a href="http://{path=products/details}{url_title}">{title}</a>
{/exp:weblog:entries}
{/exp:category_id}
Hi brittanyA,
Yes, you can achieve this by writing the code as this:
{exp:child_categories parent="18|29" child_categories_sort_by="custom" child_categories_sort_direction="asc" site="1"}
{parent_category_start}
{if "{parent_category_children_count}" > 0}
Some code
{/if}
{parent_category_end}
{/exp:child_categories}
Laisvunas, love your plugin it’s saved me SO much time.
I am however running into a problem that I’m hoping there is a simple answer to. I want to show a list of 3 random child categories from one parent. Is this somehow possible? I’ve read over the documentation and I can’t seem to find anything that will allow me to do that. Any advice would be appreciated.
Thanks,
-kev
Hi Kev,
What you need is in principle achievable.
Two things are missing:
1) plugin which would expose PHP rand() function through EE tag;
2) Child Categories plugin variable {child_category_count} which would output count number of the child category.
Both would be good to have. I will try to implement these things in forthcomming days.
Hi Laisvunas.
Would you have any comments or resolution regarding my earlier note quoted below? Since then, I have installed your latest 1.5.1 version but the problem is still the same.
- Category custom field: Hmmm… In the following code, the value of the category custom field ({sitemap_template}) that is retrieved is the one of the parent, not the one of the child. I use it in the child’s URL to define what template should be used.<ul> {exp:weblog:entries weblog="{my_weblog}"} {categories} {exp:child_categories parent="{category_id}" child_categories_sort_by="custom" show_empty="yes"} {child_category_start} <li><a href="/index.php/{sitemap_template}/c/{child_category_url_title}">{child_category_name}</a> {if "{child_category_description}"} {child_category_description}{/if}</li> {child_category_end} {/exp:child_categories} {/categories} {/exp:weblog:entries} </ul>
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.