We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

orderby surname on exp:channel:entries

Development and Programming

Ralph's avatar
Ralph
78 posts
14 years ago
Ralph's avatar Ralph

Hi. I have a list of <li>’s with people in as follows:

{exp:channel:entries channel="our_people" category="{cat_id}" orderby="title" sort="asc"} 
<li><a href="http://{title_permalink={segment_1}/{segment_2}/{segment_3}}class=active">{title}</a></li>
{/exp:channel:entries}

I need to order them by surname then forename. I came up with a way to do this in mysql (below) but I’m not sure how to get {exp:channel:entries} to use this. I tried putting the concat(..) statement in the orderby=”“ parameter but no luck. I’m not so keen on using a {exp:query} tag to do it as I imagine it would be quite complicated, is there any other way?

SELECT cat_id, 
concat(substring_index(title,' ',-1), substring_index(title,' ',1)) as title_order 
FROM exp_categories order by title_order

Any help much appreciated!

       
Ralph's avatar
Ralph
78 posts
14 years ago
Ralph's avatar Ralph

I gave up on this and added a Surname field to order by instead.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.