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.

Show content based on what category

November 13, 2012 6:31pm

Subscribe [4]
  • #1 / Nov 13, 2012 6:31pm

    I’ve got a single template that I’d like to show some different content in a sidebar based on what category someone is on.

    {exp:channel:entries channel="pages"}
        {if category_id=="41"}
     <h4>Related Articles</h4>
    <p>    {/if}<br />
    {/exp:channel:entries}

    So above, I’d like to show the h4 “Related Articles” if the page that the user is on was assigned to that category.
    I’m currently trying to use the category id but that doesn’t work.

  • #2 / Nov 14, 2012 9:46am

    Boyink!

    5011 posts

  • #3 / Nov 15, 2012 12:40pm

    It’s a little trickier than that.

    So I’ve got this

    <h4>Related Video Links</h4>
    
    <p><br />
    {exp:channel:entries related_categories_mode="yes" custom_fields="yes"}<br />
           <ul><br />
      <li><a href="http://{title_permalink}">{title}</a></li><br />
     </ul><br />
    {/exp:channel:entries}

    The h4 tag is what I want to change based on which category it is.
    I’ve got 3 categories (videos, articles, presentations). So whenever someone is on a video page, I want the related video page links to show (which they do) but also show that h4 tag to say “Related Video Links”.
    And then if they’re on a article page, I want that h4 tag to say “Related Article Links”.

    Hopefully that makes sense.

  • #4 / Nov 15, 2012 12:42pm

    Boyink!

    5011 posts

    There are {category}{/category} tags for displaying category information within the channel:entries tag pair.

  • #5 / Nov 15, 2012 2:19pm

    Shane Eckert

    7174 posts

    Hey skodaminotti,

    I am glad that Mike was able to help you out with categories here.

    Do you understand what he is referencing? It would look like this.

    {categories}
    <a href="http://{path=channel/index}">{category_name}</a>
    {/categories}

    Cheers,

     

  • #6 / Nov 15, 2012 2:47pm

    Here’ what I’ve got so far:

    {exp:channel:entries related_categories_mode="yes" custom_fields="yes"}
    {categories}
    <h4>Related {category_name} Links Here</h4>
    <p>{/categories}<br />
           <ul><br />
      <li><a href="http://{title_permalink}">{title}</a></li><br />
     </ul><br />
    {/exp:channel:entries}

    The h4 doesn’t show up. Here’s a look at the live page, it’s the links in the sidebar
    http://financial.skodaminotti.com/estate-planning-calculators
    I want to show a different h4 for each group of category links.

  • #7 / Nov 15, 2012 4:16pm

    Shane Eckert

    7174 posts

    Hey there skodaminotti,

    What channel are you pulling from? You Channel Entries does not specify.

    Cheers,

  • #8 / Nov 16, 2012 2:47pm

    {exp:channel:entries channel="pages" related_categories_mode="yes" custom_fields="yes"}
    {categories}
    <h4>{category_name}</h4>
    <p>{/categories}<br />
           <ul id="sidebar-links"><br />
      <li><a href="http://{title_permalink}">{title}</a></li><br />
     </ul><br />
    {/exp:channel:entries}

    I still get nothing in the h4. Nothing even shows up in the source.

  • #9 / Nov 16, 2012 2:49pm

    Shane Eckert

    7174 posts

    Hey there skodaminotti,

    Do you have any entries in the pages channel and do those entries have any categories assigned to them?

    Cheers,

  • #10 / Nov 16, 2012 2:51pm

    Yes I have entries in that channel and have them assigned to categories. For instance, this page http://financial.skodaminotti.com/insurance-calculators
    shows all the pages entries as links in the sidebar.

  • #11 / Nov 20, 2012 5:12pm

    Shane Eckert

    7174 posts

    Hey there skodaminotti,

    I would like to get a look at what’s going on.

    Please be on the lookout for an email from EllisLab.

    Cheers,

  • #12 / Nov 21, 2012 9:33am

    Shane,

    I just replied to that email. Thanks.

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

ExpressionEngine News!

#eecms, #events, #releases