Hi All,
I set up categories hierarchical structure like:
Cat 1
--- Cat 2
--- Cat 3
--- Cat 4
Cat 5
--- Cat 6
--- Cat 7
And with entries, I would like to display as follow format:
Cat 1
--- Cat 2
--- entry 1
--- entry 2
--- Cat 3
--- entry 3
--- Cat 4
--- entry 4
Cat 5
--- Cat 6
-- entry 5
--- Cat 7
I am using the following code, I could display all categories but not entries
{exp:channel:categories category_group="3" parent_only = "yes" style="linear"}
<h2>{category_name}</h2>
{exp:gwcode_categories channel = "education_standard" cat_id="{category_id}" style="linear" entry_count="yes"}
{if !depth1_start}<h3>{cat_name} {cat_id} {entry_count}</h3>{/if}
{exp:channel:entries channel="education_standard" category='{cat_id}' dynamic="no"}
{title}
{/exp:channel:entries}
{/exp:gwcode_categories}
{/exp:channel:categories}
I found that the {cat_id} is not pass to exp:channel:entries. If I hard code {cat_id}, i.e. {exp:channel:entries channel="education_standard" category='21' dynamic="no"}, the {title} will come up. Does anyone know why I could pass the dynamic category id to exp:channel:entries, so that it display the entries?
Thanks, Angela
Angela, I took a closer look at the code and the issue is that you’re nesting a channel entries tag inside a channel categories tag. You’ll need to remove the channel entries and do it with an embed:
{embed="embeds/your-embed" cat_id="{cat_id}"}
Then in your embed you’ll have the following:
{exp:channel:entries channel="education_standard" category='{embed:cat_id}' dynamic="no"}
{title}
{/exp:channel:entries}
Hope that works for you!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.