Jump to content

Recommended Posts

Posted

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?

Posted

Nope but you could store the weekday to a field and sort by it. This could be saved with a save hook.

Posted

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");
 
  • Like 7
Posted

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!

  • Like 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...