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 with conditional?

August 07, 2007 1:24pm

Subscribe [2]
  • #1 / Aug 07, 2007 1:24pm

    vmills

    96 posts

    I have a set of entries with two custom date fields: conf-date and pub-date. I have a conditional in the code below for displaying the proper date. I’d like to have the entries sorted using the same conditional, rather than just pub-date as shown in the code. Is this possible? (FYI, I’m using the entry date in a different template so I can’t use it here to manipulate the display order).

    {exp:weblog:entries weblog="cme" orderby="pub-date" show_expired="yes"}
    <a href="http://{permalink=programs/detail}">{webtitle}</a>
    {if cme-subtitle}{cme-subtitle}
    {/if}
    {if conf-date}{conf-date format="%F %Y"}
    {if:else}{pub-date format="%F %Y"}{/if}
    {/exp:weblog:entries}
  • #2 / Aug 08, 2007 12:03pm

    Robin Sowell

    13255 posts

    I’m not thinking of a way using the weblog tag.  You can pipe an order by- orderby=“conf-date|pub-date” - but what that does- first it orders by conf-date and then within the same conf-date it will order by the pub-date.  If you don’t have a conf-date, that will be a 0- so all of the ones with no conf-date would be lumped together in your order and within that ‘lump’ they’d be ordered by pub-date.  Which isn’t what you’re going for.

    Could probably do it via the query module- I THINK.  I’ve never written one quite like that.  But it’s worth a shot of that’s the only data you need to show.  If you’re pulling in categories and such and need this to be dynanmic, that would become problematic.

  • #3 / Aug 08, 2007 12:47pm

    vmills

    96 posts

    Thanks Robin. I think I’ll find another way to display the information. I’m not very proficient in SQL queries and I don’t think this issue is worth the trouble (assuming I could even get it to work). But it’s good to know for future reference some of the limitations on that orderby parameter.

  • #4 / Aug 08, 2007 12:51pm

    Robin Sowell

    13255 posts

    There are some third party plugins that affect the display order.  Rather than doing the ordering in the query, you might could just change up the order of the display.  Now- that would be a problem if you’re paginating, but if you aren’t, do a quick search around.  I know I’ve seen some references to plugins that do this.  Just never played with one myself.  But- that might be another option.

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

ExpressionEngine News!

#eecms, #events, #releases