ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

not show parent categories

August 09, 2010 10:35am

Subscribe [2]
  • #1 / Aug 09, 2010 10:35am

    petattlebaum

    60 posts

    I would like to show only the entries in the parent category (490)...not the entries in the subcategory (499)
    The code below shows entries from both so obviously its wrong.

    My ee settings have parent categories automatically assigned to entries.

    Am I close?

    Thanks
    Peter T

    {categories}{if:elseif category_id == '490' && parent_id == '0'}{/categories}
               <ul>
                     {embed="eeos/menu_embed" catg="490"}
               </ul>
  • #2 / Aug 09, 2010 3:51pm

    Green Egg Media

    111 posts

    petattlebaum -

    I’m not sure what the {categories}{/categories} tag is that you’re using. This doesn’t seem to be a valid tag. It’s also not clear why you’re using an if:elseif statement when there is only one conditional, and you never close the conditional. You are also using parent_id, which is a variable of the {exp:channel:categories}{/exp:channel:categories} tag pair, but it seems you are trying to display entries, not categories.

    Is there more to the code that you haven’t included here?

    Also, you are passing a catg variable to the embedded template, but you haven’t shown how you’re using that variable in the embedded template, so it’s hard to say if there might be a problem there, as well.

    At the very least, you probably need to use the {exp:channel:entries}{/exp:channel:entries} tag pair to get the entries that you want. I suggest something like this might work to get you started, but there’s a lot I don’t know about what you’re trying to do:

    {exp:channel:entries category="490"}
       Other variables and HTML mark-up here
    {/exp:channel:entries}

    If you can post any other code that is relevant, for instance, the eeos/menu_embed template, that might help me provide greater guidance.

    Lance
    Green Egg Media

  • #3 / Aug 09, 2010 4:44pm

    petattlebaum

    60 posts

    Lance,

    You hit the nail right on the head.  I am/was definitely trying to use tags to display entries and not categories.  I sure did leave some code out. 
    My hope/plan is that if the entry (segment_3) is in category 490 (the parent category), that only those entry titles would appear in the menu part of the page.
    If the entry (segment_3) is in category 499 (who’s parent category is 490), then only the titles of the category 499 entries would appear in the menu area.

    Here’s the code on menu part of my main page:

    {if segment_2 == 'info'}
        {exp:weblog:entries weblog="eeos"}
    {categories}{if category_id == '490' && parent_id == '0'}{/categories}
               <ul>
                     {embed="eeos/menu_embed" catg="490"}
               </ul> 
    {categories}{if:elseif category_id == '499' && parent_id == '490'}{/categories}
               <ul>
                     {embed="eeos/menu_embed" catg="490"}
               </ul> 
        {/exp:weblog:entries}

    Here’s the menu_embed code:

    {exp:weblog:entries weblog="eeos" category="{embed:catg}" disable="member_data|trackbacks" dynamic="off" orderby="title" sort="asc"}
    <li> <a href="http://{path=">{title}</a></li>          
    {/exp:weblog:entries}

    Thanks again for your help.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases