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.

Using two fields in the "orderby" parameter does not work.

November 08, 2012 12:45pm

Subscribe [2]
  • #1 / Nov 08, 2012 12:45pm

    antiuser

    44 posts

    I have a list of names that need to populate a dropdown, and I’ve noticed that even though I have orderby=“last_name|first_name” sort=“asc” on my channel entries tag, the entries are only ordered by last name but not first name. This causes issues with the listing where “Jeffrey Adams” will show up before “Bob Adams”. I know I can probably just replace the channel entries tag with a straight SQL query, but then that won’t be cached and it’ll cost me more loading time. I believe this is a bug.

    Here’s my full channel entries tag:

    {exp:channel:entries channel="physician_database" dynamic="no" orderby="last_name|first_name" sort="asc" limit="999"}
    <option value="{site_url}search/physician_profile/{url_title}">{first_name} {if middle_initial}{middle_initial}.{/if} {last_name}{if degree}, {degree}{/if}</option>
    {/exp:channel:entries}
  • #2 / Nov 09, 2012 3:29pm

    Shane Eckert

    7174 posts

    Hey there antiuser,

    Try this.

    {exp:channel:entries channel="physician_database" dynamic="no" orderby="first_name|last_name" sort="asc" limit="999"}

    Let me know if that works.

    Cheers,

  • #3 / Nov 09, 2012 4:09pm

    antiuser

    44 posts

    That doesn’t work. I need it to be ordered by last name first, then by first name. For instance, people with the last name “Adams” would show up at the top of the list. With your example, it is putting the first names that begin with A at the top.

  • #4 / Nov 09, 2012 4:11pm

    Shane Eckert

    7174 posts

    Hi antiuser,

    Can you show me an example of the results?

    I tried this in my own install and it works.

    Thank you,

  • #5 / Nov 09, 2012 4:21pm

    antiuser

    44 posts

    Hi Shane, I tried to send you a PM but your mailbox is full. Your example is putting the first names that begin with A at the top of the list, when the list should really be master ordered by the last name, with a secondary sort by first name just to make sure that “Jeffery Adams” doesn’t show up higher than “Bob Adams”, for instance.

  • #6 / Nov 09, 2012 4:38pm

    Shane Eckert

    7174 posts

    Hi antiuser,

    Right, we disable out PM’s. It keeps folks from sending us sensitive information.

    I was just hoping for a list or screenshot.

    I use those two names among others and my list looks right. Bob comes before Jeffery.

    What version of ExpressionEngine are you currently on?

    Cheers,

  • #7 / Nov 09, 2012 4:41pm

    antiuser

    44 posts

    We are on 2.5.2

    I set up two templates, one with the code we currently have and one with your example. You can see the issue:

    https://www.evergreenhealth.com/shane_example
    https://www.evergreenhealth.com/original_code

  • #8 / Nov 09, 2012 4:58pm

    Shane Eckert

    7174 posts

    Hi antiuser,

    Wow. Seems like we get different results between the two version.

    Please be on the lookout for an email from EllisLab.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases