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.

Possible to display entries two different ways with a single exp:channel:entries call?

November 21, 2011 3:09pm

Subscribe [3]
  • #1 / Nov 21, 2011 3:09pm

    astuteo

    36 posts

    I have 6 news articles. I would like to structure the first 2 as featured and the remaining 4 as smaller sublinks. Is there any way to do this with a single call for the latest 6 entries, as opposed to calling 2 and then calling 4 with the offset?

  • #2 / Nov 22, 2011 7:48am

    Mark Bowen

    12637 posts

    Hi astuteo,

    If it’s always just 6 entries broken up into 2 and 4 then yes you could do something like this :

    {exp:channel:entries
     channel="default_site"
     limit="6"
     disable="member_data|trackbacks|categories|category_fields|pagination"}
    
    {if count == "1" OR count == "2"}
    Markup for items 1 & 2…
    {if:else}
    Markup for other 4 items here…
    {/if}
    
    {/exp:channel:entries}

    Hope that helps a bit.

    Best wishes,

    Mark

     

  • #3 / Nov 22, 2011 9:29am

    astuteo

    36 posts

    Cool, thanks! So follow-up question, is that any more efficient/faster etc than making two separate calls with exp:channel:entries tags?

  • #4 / Nov 22, 2011 9:31am

    Mark Bowen

    12637 posts

    Hiya,

    I would say it’s definitely more efficient yes as there will be less database calls to the system.

    If you want to find out if it is indeed faster / more efficient though you could code up two different templates with the two separate methods in them and turn on Template Profiler to see how long / how many queries each method makes though.

    Best wishes,

    Mark

  • #5 / Nov 22, 2011 9:42am

    astuteo

    36 posts

    Thanks, brother. Will do.

  • #6 / Nov 22, 2011 3:16pm

    Kevin Smith

    4784 posts

    Glad Mark was able to help you out, astuteo! Let us know if there’s anything we can do to help.

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

ExpressionEngine News!

#eecms, #events, #releases