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.

last_result variable?

September 07, 2007 12:52pm

Subscribe [2]
  • #1 / Sep 07, 2007 12:52pm

    Jan_Huygens

    106 posts

    In a single entry page I have a section which consists of a header and a unordered list of related items. 

    <h2>Case studies</h2>
    <p>  <ul><br />
      {exp:weblog:entries weblog="w_casestudies" custom_fields="on" related_categories_mode="on"}<br />
        <li><a href="http://{title_permalink=">{title}</a></li><br />
      {/exp:weblog:entries}<br />
      </ul>

    This works fine.

    However, when there are no results, I just get a header, and an empty <u></ul>. Clearly, I would like to suppress this if possible. any ideas?

    I could use the {count} variable to do the header and opening <ul>, but can’t see how to determine the last result

    {exp:weblog:entries weblog="w_casestudies" custom_fields="on" related_categories_mode="on"}
        {if count==1}
          <h2>Case studies</h2>
    <p>      <ul><br />
        {/if}</p>
    
    <p>    <li><a href="http://{title_permalink=">{title}</a></li></p>
    
    <p>     {if ????? }<br />
         </ul><br />
         {/if}<br />
      {/exp:weblog:entries}

    Have I missed a usefull variable?

    thanks

  • #2 / Sep 07, 2007 12:55pm

    Lisa Wess

    20502 posts

    How about comparing count to total_results?

  • #3 / Sep 07, 2007 12:59pm

    Jan_Huygens

    106 posts

    looks promising - thanks

    yup - that did the trick.  Guess my eye skipped over that one when scanning the variables list 😊

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

ExpressionEngine News!

#eecms, #events, #releases