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.

Conditionals within entry_titles

October 05, 2010 1:03pm

Subscribe [3]
  • #1 / Oct 05, 2010 1:03pm

    dhc

    86 posts

    Hi,

    I’m using the exp:weblog:category_archive tag to output a list of all categories and their entries.  I’d like to wrap one of the entries in a class that will change the colour of the text but I can’t get the conditional to work.

    The code I’m using is:

    {exp:weblog:category_archive weblog="caseStudies" sort="asc" orderby="date" style="nested" 
    show_empty="no" class="first-submenu" id="submenu"}
       {categories}
         {category_name}
       {/categories}                
       {entry_titles}
         <a href="http://{path=%27part-time-finance-directors/case-studies/%27}" title="{title}">_{if title == "Services to the marketing media and technology sectors"}_<span class="caseStudyHighlight">{title}</span>{if:else}{title}{/if}</a>
       {/entry_titles}
     {/exp:weblog:category_archive}

    The strange thing is if I change the conditional to != the class is added, so it seems conditionals do work inside these tags.  But I can’t get it to check and respond to the one entry I want it to.

    I’ve tried {if title, {if url_title, {if entry_id, all to no avail.

    Thank you.

    Moved to CodeShare Corner by Moderator

  • #2 / Oct 05, 2010 7:08pm

    Sue Crocker

    26054 posts

    dhc, which build/version of EE1.x are you using? You can see that at the bottom of any control panel page.

  • #3 / Oct 06, 2010 3:03am

    dhc

    86 posts

    Hi Sue,

    it’s 1.6.6 and Build 20081212

  • #4 / Oct 06, 2010 3:34pm

    Ingmar

    29245 posts

    Can you please upgrade to a more recent build? 1.6.9 would be the current one. It’d mean we’re all on the same page in terms of code.

  • #5 / Oct 08, 2010 4:12am

    dhc

    86 posts

    Sure, just done that.  Now on 1.6.9 and build: 20100805

  • #6 / Oct 08, 2010 10:16am

    Ingmar

    29245 posts

    Try using simple conditionals, like so:

    {exp:weblog:category_archive ...}
    ...
       {entry_titles}
         <a href="http://...">_     {if title == "foo"}<span class="caseStudyHighlight">{/if}_       {title}_     {if title == "foo"}</span>{/if}</a>
      {/entry_titles}
    {/exp:weblog:category_archive}
  • #7 / Oct 08, 2010 10:36am

    dhc

    86 posts

    That didn’t work I’m afraid, unless I’ve misunderstood you.

    The code I’m using is

    {entry_titles}
         <a href="http://{path=part-time-finance-directors/case-studies/}">_       {if title == "Services to the marketing media and technology sectors"}<span class="caseStudyHighlight">{/if}_       {title}_       {if title == "Services to the marketing media and technology sectors"}</span>{/if}_     </a>
      {/entry_titles}
  • #8 / Oct 08, 2010 11:26am

    Ingmar

    29245 posts

    Can you try a minimalist template:

    {categories}
       ...
    {/categories}
    
    {entry_titles}
       <a href="http://{path=SITE_INDEX}">_   {if title == "foo"}<span class="caseStudyHighlight">{/if}_   {title}</a>
    
       {if title == "foo"}</span>{/if}
       </a>
    {/entry_titles}
  • #9 / Oct 08, 2010 11:59am

    dhc

    86 posts

    Done, you can see it here: http://fdsolutions.uk.com/index.php/dev/

    Using this code:

    {exp:weblog:category_archive weblog="caseStudies" sort="asc" orderby="date" style="nested" show_empty="no" class="first-submenub" id="submenu2"}
      {categories}
        <h2>{category_name}</h2>
    <p>  {/categories}                <br />
      {entry_titles}<br />
        <a href="http://{path=SITE_INDEX}">_      {if title == "Services to the marketing media and technology sectors"}<span class="caseStudyHighlight">{/if}_      {title}_      {if title == "Services to the marketing media and technology sectors"}</span>{/if}_    </a><br />
      {/entry_titles} <br />
    {/exp:weblog:category_archive}

  • #10 / Oct 08, 2010 5:14pm

    Sue Crocker

    26054 posts

    I see what you mean. I can replicate the problem you’re having. The if title isn’t working.

    However, see Grant’s comments on this docs page: http://expressionengine.com/legacy_docs/modules/weblog/category_archive.html#varpair_entry_titles

    Would that help?

  • #11 / Oct 11, 2010 1:12pm

    dhc

    86 posts

    It did, thank you.  Well mostly.

    I’m using D-Rock’s solution and on some pages everything works fine.

    The strange thing is on other pages, pages that I think use the exact same code (since the nav is in one template which is embedded into all others), the third level navigation is not appearing, or appearing strangely.

    So the Case Studies menu here: http://fdsolutions.uk.com/index.php works as it should, with all the categories listed and all the entries within each category listed too.

    However, on this page: http://fdsolutions.uk.com/index.php/part-time-finance-directors/about-us/why-choose-us all the categories are listed as they should be (Construction and Property, Consumer Goods, Engineering and Industrial) but the entries themselves aren’t.

    Even stranger (or perhaps more illuminatingly), going to any entry within Case Studies means the nav shows the category listing as it should and then only the entry for the category chosen.  So for example this page http://fdsolutions.uk.com/index.php/part-time-finance-directors/case-studies/waste-management-and-construction shows the link for “Waste management and construction” within the first category “Construction and property” but no others.

    The code I’m using is:

    <ul>
          <li><h2><!--[if IE 6]><a href="/index.php/part-time-finance-directors/case-studies"><![endif]-->Sectors & Case Studies<!--[if IE 6]></a><![endif]--></h2>
    <p>        {exp:weblog:categories weblog="caseStudies" sort="asc" orderby="date" style="nested" show_empty="no" disable="category_fields" class="first-submenub" id="submenu2"}<br />
              {category_name}<br />
                <ul><br />
                  {exp:weblog:entries weblog="caseStudies" category="{category_id}" sort="asc" orderby="date" }<br />
                    <li><br />
                      <a href="/index.php/part-time-finance-directors/case-studies/{url_title}">{if title == "Services to the marketing media and technology sectors"}<span class="caseStudyHighlight">{title}</span>{if:else}{title}{/if}</a> <br />
                    </li><br />
                  {/exp:weblog:entries}<br />
                </ul><br />
              {/exp:weblog:categories} <br />
          </li><br />
      </ul>


    My guess is it’s a problem with category=”{category_id}” but it’s purely a guess because I’ve never really got my head around how that parameter works.

  • #12 / Oct 12, 2010 3:02pm

    Ingmar

    29245 posts

    Thank your for the detailed feedback. You’re up and running, I understand?

  • #13 / Oct 12, 2010 3:05pm

    dhc

    86 posts

    Hi Ingmar,

    not exactly.  I’m having the problem I wrote about above.  Wondered if anyone could help me get to the bottom of it.

  • #14 / Oct 13, 2010 10:16am

    Sue Crocker

    26054 posts

    Hi, dhc. I’m going to move this to the CodeShare Corner for additional community support.

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

ExpressionEngine News!

#eecms, #events, #releases