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.

Categories variable pair not parsing

March 31, 2011 12:09pm

Subscribe [3]
  • #1 / Mar 31, 2011 12:09pm

    EyelightInc

    19 posts

    {exp:channel:entries channel="projects" sort="desc" status="Open|Featured" paginate="top" limit="8" }
          {if absolute_results <= 8 && count == 1}
            <div id="projpgbrowse">
            <div id="projfilterby">
              {if segment_2 == "cat"}
                <h2>{categories}{category_name}(/categories}</h2>
    <p>          {if:else}<br />
                </p><h2>All Projects</h2>
    <p>          {/if}<br />
            </div><!-- end of #projfilterby -->  <br />
          </div><!-- end of #projpgbrowse --><br />
          <div id="projcasewrap"><br />
          {/if}<br />
    {/exp:channel:entries}

    I’m trying to display what category you’re currently filtering search results by, but

    {categories}{category_name}(/categories}

    wont parse.

    Any ideas? Thanks!

  • #2 / Mar 31, 2011 12:54pm

    Brett Gullan

    70 posts

    ansonleclair, try something like this (not tested):

    <h2>{categories}{if '{segment_3}' == '{category_id}'}{category_name}{/if}{/categories}

    ... I’m assuming {segment_3} contains the Category Id of the category you want to display.

    HTH

  • #3 / Mar 31, 2011 2:51pm

    EyelightInc

    19 posts

    thanks for the reply Brett,

    segment_3 actually contains the Category URL Title.

    I tried:

    <h2>{categories}{if '{segment_3}' == 'water_service'}{category_name}{/if}{/categories}</h2>

     

    and the if statement processed, but I still see displayed on the webpage:

    {categories}{category_name}{/categories}

    instead of it displaying the value of the variable {category_name}.

    I’m using pagination, could that be affecting it?

  • #4 / Mar 31, 2011 8:26pm

    Brett Gullan

    70 posts

    ansonleclair, have you checked your code (syntax)? I noticed your closing {/categories} has a round opening brace (not a curly one)!

  • #5 / Mar 31, 2011 8:33pm

    Brett Gullan

    70 posts

    Also, if you only want to display info for the Category currently being displayed, try using this tag:

    http://ellislab.com/expressionengine/user-guide/modules/channel/category_heading.html

    B.

  • #6 / Mar 31, 2011 8:34pm

    Brett Gullan

    70 posts

    This extension might be better still ...

    http://loweblog.com/software/low-seg2cat/

  • #7 / Mar 31, 2011 11:01pm

    John Henry Donovan

    12339 posts

    ansonleclair,

    Let us know if Brett’s advice is helpful.

    I would usually use the Category Heading tag in this instance

    {if segment_2 == "category"}
    {exp:channel:category_heading channel="projects"}
    <div id="projpgbrowse">
            <div id="projfilterby">
    <h2>{category_name}</h2>
    <p></div><!-- end of #projfilterby -->  <br />
    </div><!-- end of #projpgbrowse --><br />
    {if:else}</p><h2>All Projects</h2>
    <p>{/if}</p>
    
    <p><br />
    {/exp:channel:category_heading}<br />
    {exp:channel:entries channel="projects" sort="desc" status="Open|Featured" paginate="top" limit="8" }<br />
        <br />
          <div id="projcasewrap"><br />
        <br />
    {/exp:channel:entries}

  • #8 / Apr 01, 2011 10:54am

    EyelightInc

    19 posts

    Brett and John thanks so much, that got it working! I wound up using the {exp:channel:category_heading} tag you have both suggested.

    I guess you can’t use the {categories} variable pair in a pagination area, that was my only issue. I’m not sure why, is it because you can’t nest any type of tags like this?

    Thanks again!

  • #9 / Apr 04, 2011 11:40am

    Sue Crocker

    26054 posts

    Hi, ansonleclair.

    Sounds like you have a solution—Feel free to start a new thread if you have any more questions.

  • #10 / Apr 04, 2011 11:40am

    Sue Crocker

    26054 posts

    Now really closing..

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

ExpressionEngine News!

#eecms, #events, #releases