Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Sort back-end (BlogEntry's)


Reply

2 Posts   1170 Views

Avatar
borriej

9 February 2011 at 3:48am Community Member, 267 Posts

How can i sort my blogentry's by date?

Tried things like this, but its not working for me:

SiteTree::$default_sort = 'IF("SiteTree"."ClassName" = \'BlogEntry\', LOWER("SiteTree"."DESC"), "SiteTree"."Sort")';
SiteTree::$default_sort = 'IF("SiteTree"."ClassName" = \'BlogEntry\', LOWER("SiteTree"."Created"), "SiteTree"."Sort")';
SiteTree::$default_sort = 'IF("SiteTree"."ClassName" = \'BlogEntry\', LOWER("SiteTree"."Created"), "SiteTree"."Created")';

The search form didn't give me much help.

Avatar
adiwidjaja

28 May 2011 at 3:38am Community Member, 14 Posts

Late answer, but maybe someone else needs this - I found this solution:

SiteTree::$default_sort = 'IF("SiteTree"."ClassName" = \'BlogEntry\', NOW() - "SiteTree"."Created", "SiteTree"."Sort")';

Cheers,

Andy