Jump to content

Use hook to change order of child pages in site tree


DrQuincy
 Share

Recommended Posts

I have a template that has a date field attached to it and I use this to reverse sort items.

This works great for my blog feed. However, I want to use the same template for an events field. To save me managing an entirely separate template, is there a hook I can use that will uncheck the “reverse sort” checkbox dyanically?

So:

/blog/ sorts children per the template settings, most recent first
/events/ uses a hook to display pages date order ascending

Note I am only referring to the site tree in the admin. Obviously, on the front end I can easily use selectors to get the desired result.

Thanks.

 

Link to comment
Share on other sites

Thanks but I want to use different sorting dynamically though to avoid adding a separate template.

One is news, most recent first. The other is events where the date would be ascending since the dates would be in the future.

I hope that makes sense.

Link to comment
Share on other sites

Yes, you can do it by changing the parent page template sorting option. The child template doesn't change, only the sort option on parent page template.

/blog/ sorts childrenmost recent first
/events/ sorts children: date order ascending

Edited by da²
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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