We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Entry Categories

Development and Programming

Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

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}
       
Adrienne L. Travis's avatar
Adrienne L. Travis
213 posts
15 years ago
Adrienne L. Travis's avatar Adrienne L. Travis

Laisvunas,

Thanks, that helps a lot!

Adrienne

       
Dylan Smith/Context Design's avatar
Dylan Smith/Context Design
346 posts
15 years ago
Dylan Smith/Context Design's avatar Dylan Smith/Context Design

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!

       
Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

Check if the tag exp:entry_id and the tag exp:entry_cats has correct output when used separately.

       
Dylan Smith/Context Design's avatar
Dylan Smith/Context Design
346 posts
15 years ago
Dylan Smith/Context Design's avatar Dylan Smith/Context Design

Hmm, whatever was funky seems to have righted itself - some sort of caching issues, maybe.

Although, I’ll be trying the good-old fashioned {categories} tag instead - I need the looping ability, I think.

Thx!

       
arteylogica's avatar
arteylogica
37 posts
15 years ago
arteylogica's avatar arteylogica

Hi, this plugin just saved my ass.

I have a question: How can I output more than 1 child category?

Let’s say under the Category “California” I selected two child cateogries “Los Angeles” and “San Diego”.

Can I do this?

Thanks for your work!

G.

       
Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas
How can I output more than 1 child category?

Write the code as this:

{level1_category0_cat_name}, {level1_category1_cat_name}, {level1_category2_cat_name} ...
       
LucPestille's avatar
LucPestille
146 posts
15 years ago
LucPestille's avatar LucPestille

It would be great if you could add in the “backspace” function to this plugin - when you’re getting a list of categories, they usually have something like a comma after each, which I need to remove after the last one…

       
Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

Hi Luc,

This plugin does not loop through tagdata, so, there is no need for “backspace” parameter.

       
fanderson's avatar
fanderson
883 posts
15 years ago
fanderson's avatar fanderson

Hi Laisvunas,

I would like to display the category_name of the current entry where the category is a subcategory and shows up in segment 3.

Is this possible with this plugin? If so how?

Thanks.

       
Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

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}
       
fanderson's avatar
fanderson
883 posts
15 years ago
fanderson's avatar fanderson

Hi Laisvunas,

It looks like the second option is the best one. My only concern is that this appears to require manual entry of the entry_id? Is it possible to capture this dynamically?

Thanks for you help,

Forrest

       
Laisvunas's avatar
Laisvunas
879 posts
15 years ago
Laisvunas's avatar Laisvunas

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}
       
fanderson's avatar
fanderson
883 posts
15 years ago
fanderson's avatar fanderson

Ah! Brilliant. Problem solved. I am set now. Thank you again for your excellent help.

Best regards, Forrest.

       
michelG's avatar
michelG
32 posts
15 years ago
michelG's avatar michelG

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

       
1 2 3

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.