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.

Category - using show for a specific child or children

February 17, 2011 12:16am

Subscribe [3]
  • #1 / Feb 17, 2011 12:16am

    Mitch Cohen

    12 posts

    I’m hitting a brick wall with categories.  Seems like this should be easy.

    To simplify, I have a parent category with two child categories.  Say the parent is 1, the children 2 and 3.  I want to display entries in category 2, but not those in category 3.  The purpose is to display chosen categories within a monthly calendar.

    I have this code:

    {exp:channel:categories channel="Calendar" category_group="1" show="1" style="linear"}
      <div class="cal_{category_id}"><a href="http://{title_permalink=.">{title}</a></div>
    {/exp:channel:categories}

    As shown (show=“1”) I get items from both categories, as I’d expect.

    I would THINK that the show=“2” would only display entries from category 2.  But it does not; it displays nothing.  If I change to show=“3” it similarly displays nothing.

    If I use shown=1|2, I get all entries TWICE - those in category 2 and those in category 3.

    How can I get ONLY those entries in child category 2?

    Using current production version, 2.1.3 build 20101220.

  • #2 / Feb 17, 2011 1:49am

    Cheif

    626 posts

    From my limited category experience, parents (always = 0) you’d need to show something like

    {exp:channel:categories channel="Calendar" category_group="1" show="not 3" style="linear"}

    The manual states that to show children you must include the parent, so set it to NOT display one of the children instead 😊

    PS. Code untested !!

  • #3 / Feb 17, 2011 3:11pm

    Marcus Neto

    1005 posts

    Mitch, If I understand correctly I think you may want to switch to the exp:channel:entries tag and limit what entries are output by the channel. Take a look at the following link

    http://ellislab.com/expressionengine/user-guide/modules/channel/parameters.html#par_category_group

    But your code may look a little something like this:

    {exp:channel:entries channel="blog" category_group="1" style="linear"}
      <div class="cal_{category_id}"><a href="http://{title_permalink=.}">{title}</a></div>
    {/exp:channel:entries}

    Also note that your code was missing a ‘} in the title permalink which (unless it was just a type) might cause some issues as well.

    Hope this helps!

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

ExpressionEngine News!

#eecms, #events, #releases