Hi Laisvunas.
I am using your plugin to dynamically generate a sidebar menu that only displays the categories for the section an entry belongs to.
For example: On a site with the following main categories/sections:
- Home
- About US
- Events
- Programs
- News
- Resources
1) If the entry is for the About Us category, the sidebar menu will look like this:
- About US
- Services
- Officers
- Committees
2) If the entry is for the Services or Service One category, the sidebar menu will look like this:
- About US
- Services
- - Service One
- - Service Two
- - Service Three
- Officers
- Committees
The code:
{assign_variable:my_weblog="pages"}
{exp:weblog:entries weblog="{my_weblog}" limit="1" disable="member_data|pagination|trackbacks"}
{exp:entry_cats entry_id="{entry_id}" parse="inward"}
<ul>
{exp:weblog:categories weblog="{my_weblog}" style="linear"}
{if {level0_category0_cat_id} == {category_id} OR {level0_category0_cat_id} == {parent_id} }
<li><a href="/index.php/{catpage_template}/c/{category_url_title}/">{category_name}</a>
{if "{level1_category0_cat_id}" == "{category_id}" }
{embed="{global_tpl}/_sideMenu_level2" entry_id="{entry_id}" my_weblog="{my_weblog}"}
{/if}
</li>
{/if}
{/exp:weblog:categories}
</ul>
{/exp:entry_cats}
{/exp:weblog:entries}
This code achieves what I want. But when the entry is for a category-level 1, it will display the following error:
Notice: Undefined index: 1 in E:\pesawebee\Hid8uL2system\plugins\pi.entry_cats.php on line 386
The {if “{level1_category0_cat_id}” == “{category_id}”} is the cause of that error.
(Before you ask: no, the embed is not the issue. In fact, you could eliminate that if statement alltogether and just keep the {level1_category0_cat_id} for testing purpose. The error will still be generated.)
Not sure if this is a bug in your excellent plugin or if it is me approaching it the wrong way.
Looking forward to your advice.
/ Michel
Plugin: pi.entry_cats_v1.2.2.zip
ExpressionEngine 1.6.8
Server: Windows NT
PHP: Version 5.2.9-2