DrQuincy Posted December 20, 2024 Posted December 20, 2024 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.
da² Posted December 20, 2024 Posted December 20, 2024 Hi, You don't need a hook, you can sort children on the parent page:
DrQuincy Posted December 20, 2024 Author Posted December 20, 2024 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.
da² Posted December 20, 2024 Posted December 20, 2024 (edited) 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 children: most recent first /events/ sorts children: date order ascending Edited December 20, 2024 by da² 1
DrQuincy Posted December 23, 2024 Author Posted December 23, 2024 Yes, good point, I don't need two different child templates. Thanks. 1
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