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.

Having Trouble With Ordered Lists in Templates

July 31, 2012 12:36am

Subscribe [4]
  • #1 / Jul 31, 2012 12:36am

    Liberty

    13 posts

    This is just a tiny thing and not really “support” worthy, but I thought someone might be able to give me a quick fix to let me know what I’m doing wrong.

    What I’m trying to do is a simple “top ten” ordered list.  The issue is that when it’s numbered, they all show as 1.

    What in the world am I missing?

    <h2>Most Popular Posts</h2>
    <p>{exp:channel:entries channel="MYCHANNEL" limit="10" orderby="view_count_one" sort="desc"}<br />
    <ol><br />
    <li>{title}</li><br />
    </ol><br />
    {/exp:channel:entries}

    Thanks in advance if anyone has any insight.  (And if not, ain’t no thang, it doesn’t have to be ordered, I just thought it’d be neat.)

  • #2 / Jul 31, 2012 6:03am

    Ralph

    78 posts

    You need the <ol> to be outside the {exp:channel:entries} tag:

    <h2>Most Popular Posts</h2>
    <p><ol><br />
    {exp:channel:entries channel="MYCHANNEL" limit="10" orderby="view_count_one" sort="desc"}<br />
    <li>{title}</li><br />
    {/exp:channel:entries} <br />
    </ol>

  • #3 / Jul 31, 2012 7:03am

    Liberty

    13 posts

    Awesome!  TYVM!

    I knew it had to be some boneheaded thing I wasn’t seeing.  Thanks much!

  • #4 / Jul 31, 2012 8:22am

    Boyink!

    5011 posts

    Alternatively, you do do something like:

    {exp:channel:entries channel="MYCHANNEL" limit="10" orderby="view_count_one" sort="desc"}
    {if count=="1"}
    <h2>Most Popular Posts</h2>
    <p><ol><br />
    {/if}<br />
    <li>{title}</li></p>
    
    <p>{if count==total_results}<br />
    </ol><br />
    {/if}<br />
    {/exp:channel:entries}

    The upside to this is approach is if the channel:entries loop happens to not return anything for some reason you won’t get an empty header/list.

  • #5 / Jul 31, 2012 1:05pm

    Shane Eckert

    7174 posts

    Hey Liberty,

    That’s awesome. I am glad that Patrick and Mike could help out here! Love the conditional that Mike used.

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases