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.

orderby status ?

October 29, 2010 7:49pm

Subscribe [5]
  • #1 / Oct 29, 2010 7:49pm

    FlashBoyz

    27 posts

    I’ve created a custom status called “featured”. Is there a way for me to order(using channels:entries) entries by status?

  • #2 / Oct 31, 2010 3:51pm

    Greg Salt

    3988 posts

    Hi FlashBoyz,

    No there isn’t, the channel://entries tag does not accept status as an orderby value. You could use the Query Module to do this though.

    Cheers

    Greg

  • #3 / Oct 31, 2010 5:11pm

    John St-Amand

    865 posts

    Or if you’re not comfortable doing that, and assuming you’re just looking to put your featured status items at the top and the rest below that, you can order within your channel entries tag - just use an if statement to look for your status to determine whether the item appears, then within that you can orderby and sort using normal methods. So:

    {exp:channel:entries channel="your_channel_name" status="feature|open" orderby="date" sort="desc" disable="whatever_your_can_disable_here" limit="20"}
    
    {if status=="featured"}
    
    put your featured items here formatting as you wish
    
    {if:elseif status=="open"}
    
    put your regular open items here, again formatted as you wish
    
    {/if}
    
    {/exp:channel_entries}

    All that would do is put your featured items at the top.  Alternatively you could simply put two channel entries tags in there separating featured from open entirely, which arguably would run a little faster perhaps since it wouldn’t have to first parse the conditional.  I’ve done it both ways, depending on what i needed to do since queries are outside my comfort zone.

    Hope that helps you!

    Jean

  • #4 / Nov 01, 2010 8:10am

    Sue Crocker

    26054 posts

    Thanks for the assist, Jean.

    FlashBoyz, It depends on what you want to do with the content after you get it. If you just want the featured items first, I’d do either two queries or two exp:channel:entries.

    Does that help?

  • #5 / Nov 01, 2010 1:10pm

    FlashBoyz

    27 posts

    Thanks guys. Yeah, I was just looking for an efficient way to display my “featured” items first. Didn’t want to go the custom field route because I like to see the custom status highlights in the CP. I think I’m just going to opt for the conditional. Thanks!

  • #6 / Nov 01, 2010 5:54pm

    Ingmar

    29245 posts

    Glad to see you found a way. Please post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases