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.

<li> issue with weblog

September 16, 2008 12:07am

Subscribe [2]
  • #1 / Sep 16, 2008 12:07am

    catch

    7 posts

    hello,

    I have tried to figure out a way but I can’t seem to.

    I would like it so it doesn’t repeat the “1.” 5 times, I want it to increase to 1-5 in each <li> item. Is it possible and how can I achieve it if it is?

    {exp:weblog:entries weblog="recent_artwork" orderby="date" sort="desc" limit="5"}
                    <li><a href="http://{recent_artwork_link}"><strong>1. </strong>{title}</a></li>
    {/exp:weblog:entries}

    I can’t just add a field for a number as the list will be updated with new items frequently.

    Thanks!

  • #2 / Sep 16, 2008 12:15am

    TechWench

    30 posts

    You can leave out the number and just you the ol tag outside of exp:weblog:entries.

    <ol>
    {exp:weblog:entries weblog="recent_artwork" orderby="date" sort="desc" limit="5"}
    <li><a href="http://{recent_artwork_link}">{title}</a></li>
    {/exp:weblog:entries}
    </ol>
  • #3 / Sep 16, 2008 12:16am

    Lisa Wess

    20502 posts

    How about using the {count} variable instead?

    <strong>{count}. </strong>
  • #4 / Sep 16, 2008 12:19am

    TechWench

    30 posts

    How about using the {count} variable instead?

    Yeah, even better! :D

  • #5 / Sep 16, 2008 12:56am

    Lisa Wess

    20502 posts

    I actually prefer your method - if you’re using a list; then an ordered list will do this semantically.  My method is better if you’re not using a list already.

    What you could do to clean yours up in case there are no entries that meet the requirements:

    {exp:weblog:entries weblog="recent_artwork" orderby="date" sort="desc" limit="5"}
    
    {if count == "1"}
    <ol>
    {/if}
    
    <li><a href="http://{recent_artwork_link}">{title}</a></li>
    
    {if count == total_results}
    </ol>
    {/if}
    
    {/exp:weblog:entries}

    Plenty of options here. =)

  • #6 / Sep 16, 2008 1:12am

    catch

    7 posts

    thank you so much for the quick help, the {count} worked perfect! 😊

    oh and btw, I can’t have a <ol> because of the certain style I need. So I am forced with the <li>

  • #7 / Sep 16, 2008 1:47am

    Lisa Wess

    20502 posts

    I’m not really following that - it is invalid to use li without an ol or ul.  If you want to validate your pages, you need to tell it what type of list and style it via CSS.

    But we’re out of EE land now, so I’ll defer to the more experienced designers. =)

  • #8 / Sep 16, 2008 1:50am

    TechWench

    30 posts

    Semantically speaking, using an li tag without an ol or ul container will produce invalid code.

    But, it won’t prevent the code li tags from displaying…just prevent it from validating.

    Unless you’re surrounding the li tags with the ul tags…then I guess that makes sense…not wanting to use the default ol list styles, maybe?

  • #9 / Sep 16, 2008 2:03am

    catch

    7 posts

    ahh I’m sorry, I am half asleep, been coding this site in EE all night,  got me all weird 😛

    I mean that I can’t use a <ol> because I can’t get a certain style with it that I can by using the <ul>.

    sorry for the confusion!

  • #10 / Sep 16, 2008 2:15am

    Lisa Wess

    20502 posts

    Ah, then count is a good option. =)

  • #11 / Sep 16, 2008 10:54am

    catch

    7 posts

    thank you lisa for your help 😊 and TechWench 😊

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

ExpressionEngine News!

#eecms, #events, #releases