EllisLab text mark
Advanced Search
     
Orderby Not working on custom date fields?
Posted: 14 May 2012 07:57 AM   [ Ignore ]
Joined: 2007-04-16
47 posts

Hi all,
  Having a little problem here, trying to do a orderby on 2 fields, first on works fine, thats just on the status, 2nd one is a custom date field. This however is not working at all.

{exp:weblog:entries weblog="wip" status="not closed" orderby="status|completion" sort="desc|desc"}
<tr class="{switch='band1|band2'}">
<
td valign="top"><p>{title}</p></td><td valign="top">{description}</td><td valign="top"><p>{support_number}</p></td><td valign="top"><p>{completion format="%d/%m/%Y"}<br />{completion}</p></td><td valign="top"><p>{quote}</p></td><td valign="top">{piroity}</td><td class="last" valign="top"><p>{status}</p></td>
</
tr>
{/exp:weblog:entries} 


Basically they get ordered by the status with no problems, it is however not ordering it by the date at all. Am I doing something stupid here or is this a bug with EE? Or does orderby for some reason not work on a custom date field even when its just returning a integer???

Thanks

Steven Lockey

Edit: More info-

Works fine if I just do ‘orderby=“completion”’ but ‘orderby=“status|completion”’ just does exactly the same as ‘orderby=“status”’ instead of ordering them by completion date when they have the same status. Its like its completely ignoring the 2nd parameter in the orderby.

 
Posted: 15 May 2012 10:42 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2011-11-25
7174 posts

Hello intunet,

I am sorry to hear you are running into this problem.

You are correct, sorting on a custom date field will not yield consistent results. Your code looks good, it’s just not going to work with custom date.

Is there anything else I can help with?

Cheers,

 Signature 

Recent version: EE 2.5.4 | Forum Module 3.1.10 | MSM 2.1.4 | 2.x Bug Tracker | Version Upgrade

 
Posted: 15 May 2012 10:49 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2007-04-16
47 posts

Out of curiosity, is there a reason why this doesn’t work?
As far as I understood it, date fields should just be # of seconds since a fixed time, aka an integer, which is about the easiest type of thing to orderby?

Or am I missing something that complicates this?

Thanks

 
Posted: 21 May 2012 03:22 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2011-11-25
7174 posts

Hello intunet,

I take this back. You are right, you can sort on a custom date field.

I tried this:

{exp:weblog:entries weblog="blog" orderby="completion" sort="asc"}
{title} 
<br{body} <br{completion}
<hr>
{/exp:weblog:entries} 

And it works for me. Trying:

{exp:weblog:entries weblog="blog" orderby="completion" sort="desc"}
{title} 
<br{body} <br{completion}
<hr>
{/exp:weblog:entries} 

also made for a happy result.

Can you try simplifying like I did and tell me what results you get?

Thank you,
Shane

 Signature 

Recent version: EE 2.5.4 | Forum Module 3.1.10 | MSM 2.1.4 | 2.x Bug Tracker | Version Upgrade