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 Field ID Problem

Development and Programming

entozoon's avatar
entozoon
2 posts
14 years ago
entozoon's avatar entozoon

Hello, I’m having a problem ordering products by price. It is in a custom text field ‘best_price’ (or ‘field_id_10’) but when I use the orderby parameter it does indeed change the ordering but not correctly.. e.g. the prices would be 125, 149, 99, etc. Here is my code (Note, I’ve tried orderby=”field_id_10” as well):

{exp:channel:entries channel="products" search:category="shirts" orderby="best_price" sort="asc" dynamic="off"}
{best_price}
{/exp:channel:entries}

-EE version: 2.1.3

       
Dave @ Exp:resso's avatar
Dave @ Exp:resso
465 posts
14 years ago
Dave @ Exp:resso's avatar Dave @ Exp:resso

Just had a similar question a few days ago actually! What you need to do is change the field content to a ‘number’, (or decimal/integer), so EE knows to sort it numerically. Its down the bottom under ‘field content’ when you go to add/edit a custom field 😊 Also set formatting to ‘none’

       
entozoon's avatar
entozoon
2 posts
14 years ago
entozoon's avatar entozoon

It’s sorted! Dave, you saved my life. Thank you so much!

I was sat here trying to write an extensive sql query that wasn’t working.. thank goodness I can scrap it :D

       
karlosb's avatar
karlosb
43 posts
14 years ago
karlosb's avatar karlosb

Dave you are a legend!

This has been doing my head in all afternoon!

Many thanks for this! 😊

       

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.