Hi Adrienne,
Use Entry Categories plugin together with Entry Id plugin:
{exp:entry_id weblog="my_weblog" url_title="my_entry" parse="inward"}
{exp:entry_cats entry_id="{entry_id_number}" site="1"}
{if category_levels_number == 2}
{level0_category0_cat_name}, {level1_category0_cat_name}
{/if}
{/exp:entry_cats}
{/exp:entry_id}
Any ideas why this isn’t working for me?
{exp:entry_id url_title="{segment_3}" parse="inward" }
{exp:entry_cats entry_id="{entry_id_number}" show="not 1|10|11|12|40|14"}
{if category_levels_number == 1}
{level0_category0_cat_name}
{/if}
{if category_levels_number == 2}
{level1_category0_cat_name}
{/if}
{/exp:entry_cats}
{/exp:entry_id}
thx!
Hi Forrest,
Use Entry Categories plugin
{exp:entry_cats entry_id="30" site="1"}
{level1_category0_cat_name}
{/exp:entry_cats}
or Category Id plugin together with either exp:weblog:entries tag
{exp:category_id category_group="2" category_url_title="{segment_3}" parse="inward"}
{exp:weblog:entries entry_id="30" site="1"}
{categories show="{category_id}"}
{category_name}
{/categories}
{/exp:weblog:entries}
{/exp:category_id}
It does not require entry_id - you can display category name without it:
{exp:category_id category_group="2" category_url_title="{segment_3}" parse="inward"}
{exp:weblog:entries weblog="my_weblog" category="{category_id}" site="1" limit="1"}
{categories show="{category_id}"}
{category_name}
{/categories}
{/exp:weblog:entries}
{/exp:category_id}
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:
1) If the entry is for the About Us category, the sidebar menu will look like this:
2) If the entry is for the Services or Service One category, the sidebar menu will look like this:
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
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.