yellowled Posted March 6, 2014 Share Posted March 6, 2014 So I have an array of pages which all have a datetime field. But it doesn't make sense to sort them by datetime in this case because the date might only be an initial date (for recurring dates). I know I can get the day of the week using strftime. Is there also some magic voodoo way to sort the array of pages according to the day of the week given by the datetime field? Link to comment Share on other sites More sharing options...
Soma Posted March 6, 2014 Share Posted March 6, 2014 Nope but you could store the weekday to a field and sort by it. This could be saved with a save hook. Link to comment Share on other sites More sharing options...
Soma Posted March 6, 2014 Share Posted March 6, 2014 There's also a way to add day to page on the fly. foreach($result as $res){ $res->day = strftime("%d",$res->getUnformatted("date")); } $results->sort("day"); 7 Link to comment Share on other sites More sharing options...
yellowled Posted March 6, 2014 Author Share Posted March 6, 2014 Wow, that is incredibly elegant. It doesn't quite do what I want, but replacing %d with %w does (all pages on a Sunday, then all pages on a Monday etc.) Thanks, soma! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now