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 Conditionals in Channel Entries?

August 06, 2010 7:01am

Subscribe [3]
  • #1 / Aug 06, 2010 7:01am

    rgbink

    63 posts

    I attempted the following and it’s failing. Seems like it should work, but no. (Below is the relevant code.)

    {exp:channel:entries channel="documents" disable="trackbacks| pagination| member_data| custom_fields| categories" limit="1"}
    
      <div class="grid_9">
        {if body}
        {body}
        {if:elseif summary}
        {if category=="3"}<h3>These are the unofficial highlights of the above-dated Board Meeting.</h3>
    <p>    This page will be updated when the final minutes are approved. Thanks for your patience.{/if}<br />
        {summary}<br />
        {if:else}<br />
        This document is currently available as a downloadable PDF only.<br />
        {if entry_file}<br />
          <a href="http://{entry_file}%22class=%22positive" class="positive download">Download this Document</a><br />
        {/if}<br />
        {/if}<br />
      </div><!--  / grid_12  --></p>
    
    <p><br />
    {/exp:channel:entries}

    What I’m trying to do is conditionally display…

    <h3>These are the unofficial highlights of the above-dated Board Meeting.</h3>
    <p>This page will be updated when the final minutes are approved. Thanks for your patience.

    …ONLY if the category of the entry is “3”
    This is on a single entry (dynamic url-driven “detail” page. KWIM?)

    Am I missing something?

  • #2 / Aug 06, 2010 8:35am

    Sue Crocker

    26054 posts

    First things first, EE2.x doesn’t come with trackbacks, try removing that from your exp:channel:entries tag.

    Also you’re disabling categories, which is why things aren’t working.


    Does that help?

  • #3 / Aug 08, 2010 8:32pm

    rgbink

    63 posts

    Well, trackbacks were part of my macro—noted.

    As for categories, no, it doesn’t help. I’d already tried that but failed to note it. Sorry.
    No, when removing *that* didn’t work, I reached out here. Of course, I’ll try removing the trackbacks as well, just in case they’re causing voodo…

    Nope. That wasn’t it.
    I’ve stared at this code endlessly. It should work. (Yes, I’ve cleaned caches. All.)

    Any other suggestions?

    Just to be clear, my current code is:

    {exp:channel:entries channel="documents" disable="pagination| member_data| custom_fields" }
    
      <div class="grid_9">
        {if body}
        {body}
        {if:elseif summary}
        {if category=="3"}<h3>These are the unofficial highlights of the above-dated Board Meeting.</h3>
    <p>    This page will be updated when the final minutes are approved. Thanks for your patience.{/if}<br />
        {summary}<br />
        {if:else}<br />
        This document is currently available as a downloadable PDF only.<br />
        {if entry_file}<br />
          <a href="http://{entry_file}%22class=%22positive" class="positive download">Download this Document</a><br />
        {/if}<br />
        {/if}<br />
      </div><!--  /grid_9  --></p>
    
    <p><br />
    {/exp:channel:entries}

    This is NOT working.

  • #4 / Aug 08, 2010 8:37pm

    Lisa Wess

    20502 posts

    All category variables must be within the categories variable pair.  You also want to compare against category_id, not category:

    {categories}
    {if category_id == "3"}blah{/if}
    {/categories}

    See categories variable pair.

  • #5 / Aug 08, 2010 9:31pm

    rgbink

    63 posts

    All category variables must be within the categories variable pair.  You also want to compare against category_id, not category:

    {categories}
    {if category_id == "3"}blah{/if}
    {/categories}

    See categories variable pair.

    :red: Ahhhh… the categories pair… yes…Thanks, Lisa!  :red:

      (That’s my blushing smiley tag pair… Stoopid stoopid stoopid!…)

  • #6 / Aug 09, 2010 3:32am

    John Henry Donovan

    12339 posts

    Glad Lisa was able to help. Feel free as always to start a new thread if you have any more questions.

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

ExpressionEngine News!

#eecms, #events, #releases