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.

Ordering by title and a custom field isn’t working

January 06, 2012 11:26pm

Subscribe [2]
  • #1 / Jan 06, 2012 11:26pm

    Jason Morehead

    456 posts

    This seems like ExpressionEngine 101, but I’m stumped… I’ve got a channel that contains library books. On the front-end, these books need to be sorted by title, then by author (since there can be multiple books with the same title). Here’s what I’ve got so far:

    {exp:channel:entries channel="books" dynamic="no" disable="categories|member_data|pagination" status="open" sticky="no" orderby="title|book_authors_sorting" sort="asc|asc" search:book_available_in_library="=Yes"}
            
    
    <a href="http://{url_title_path={segment_1}/{segment_2}/book}"><cite>{book_display_title}</cite></a> by {exp:xhtml:light}{book_authors_sorting}{/exp:xhtml:light}
    
      
    {/exp:channel:entries}

    So this should sort the books by title, then by author using the “book_authors_sorting” field (which would typically contain author last names only). However, here’s what that returns for books sharing the same title:

    Genesis by Arnold
    Genesis by Wenham
    Genesis by Hartley
    Genesis by Sailhamer
    Genesis by Reno
    Genesis by Fretheim
    Genesis by Brueggemann

    Note that the entries are not sorted by last name correctly. If, however, I change the above EE code to something like this:

    {exp:channel:entries channel="books" dynamic="no" disable="categories|member_data|pagination" status="open" sticky="no" orderby="book_authors_sorting" sort="asc" search:book_available_in_library="=Yes"}

    Then it sorts by last name correctly, but obviously, the books are no longer sorted by title alphabetically. Any ideas.

    [Mod Edit: Moved to the EE 2 Technical Support forum]

  • #2 / Jan 15, 2012 2:50pm

    Jason Morehead

    456 posts

    Any thoughts on this? I need to get back to my client with some answer/response.

  • #3 / Feb 28, 2012 10:06pm

    Jason Morehead

    456 posts

    Sorry to dredge this topic back up, but the client has been asking about this again. Any ideas?

  • #4 / Mar 05, 2012 12:26pm

    Hue Labs

    31 posts

    I’m having the same problem here: http://travelnevada.com/accommodations/ (look at the bottom of the select list).

    Here’s my simple EE code:

    {exp:channel:entries channel="cities" status="open" dynamic="no" orderby="title" sort="asc"}
      <option value="{url_title}">{title}</option>
    {/exp:channel:entries}
  • #5 / Mar 08, 2012 5:20pm

    Hue Labs

    31 posts

    Jason, I think this could be the solution: http://ellislab.com/forums/viewthread/212717/

    Basically, it was ordering by sticky (even though I didn’t explicitly say so!). Adding the parameter sticky=“off” solved my problems.

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

ExpressionEngine News!

#eecms, #events, #releases