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.

Add Count numbers to List Items

February 03, 2012 9:53am

Subscribe [2]
  • #1 / Feb 03, 2012 9:53am

    dodgson

    120 posts

    Hi There, I’m working on a rotating banner that numbers the images in the rotation. I was wondering if there is a tag that I can add to the list item that will add the incremental number, depending on the number of uploaded images.

    I.E. If there are 3 images uploaded, the List items would be numbered 1 | 2 | 3.

    Thanks in advance.

  • #2 / Feb 03, 2012 3:03pm

    Rob Allen

    3114 posts

    The {count} variable should work here:

    <ul>
    {exp:channel:entries channel="mychannel"}
    <li>{title} ({count})</li>
    {/exp:channel:entries}
    </ul>

    Should output:

    Title (1)
    Title (2)
    Title (3)

  • #3 / Feb 03, 2012 3:12pm

    dodgson

    120 posts

    Thank you for the response. Sadly this doesn’t seem to work. I tried that a little earlier. The following is the code. Do you happen to see anything glaringly obvious?

    {exp:channel:entries channel="industrial" limit="1"}
               
               
              <!--image rotation-->
              <div id="lofslidecontent45" class="lof-slidecontent">
          <div class="preload">
           <div></div>
          </div>
    
          <!-- N&C Slide Images --> 
          <div class="lof-main-outer">
           <ul class="lof-main-wapper">        
            {industrial_banners} 
             {banner_image}             
             <li>{path}_banners/{filename}.{extension}</li>
             {/banner_image}
            {/industrial_banners}
           </ul>   
          </div>
          <!-- END of N&C Slides --> 
             
          <!-- start of N&C NAVIGATOR -->
          <div class="lof-navigator-wapper">
                <div class="lof-navigator-outer">
                      <ul class="lof-navigator">
                       {industrial_banners} 
               {banner_image}
                            <li><span>{count}</span></li>
                           {/banner_image}
                          {/industrial_banners} 
                      </ul>
                </div>
           </div> 
           <!-- End of N&C NAVIGATOR -->
           
         </div>         
              <!--end of image rotation-->
             
              <h1>{industrial_title_{country_code}}</h1>
              {industrial_body_{country_code}}
        
        {/exp:channel:entries}
  • #4 / Feb 03, 2012 3:54pm

    Rob Allen

    3114 posts

    {count} only works (I believe) with Channel loops so as your example only has one “loop”/entry the count will always be 1.

    How are you generating your {industrial_banners} tag? If you’re using Matrix it has it’s own counting mechanism where row_id might work - see http://pixelandtonic.com/matrix/docs/templates

  • #5 / Feb 03, 2012 4:03pm

    dodgson

    120 posts

    You’re a Genius. I’m using Matrix, so the row_id worked perfectly. Thank you so much for your help. This one was driving me crazy.

    Take Care

  • #6 / Feb 03, 2012 4:09pm

    Rob Allen

    3114 posts

    Glad you got it sorted - the best fruit is often obscured by leaves 😊

  • #7 / Feb 03, 2012 4:11pm

    dodgson

    120 posts

    AHHH Man…. It happened that I was looking at my first entry, so the images showed up as 1 | 2 | 3. If I now go to another entry page that has it’s own rotating banner the numbers show up as 4 | 5.

    Any other thoughts. Sorry.

  • #8 / Feb 03, 2012 4:16pm

    dodgson

    120 posts

    Just found the answer from your last link. You need to use the Matrix {row_count}.

    Thanks again for your help and sending me in the right direction.

    Take Care
    Mark

  • #9 / Feb 04, 2012 4:00pm

    Dan Decker

    7338 posts

    Hi Mark,

    I’m glad Rob was able to help you get sorted out!

    If you need anything else in the future, please feel free to start a new thread.

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases