ro-bo Posted November 24, 2017 Share Posted November 24, 2017 Hi, Is there an easy way to change the sorting of the template-selection when adding pages (Page Add Process)?It would be nice if sorting in the select-field is by template-title instead of template-name... E.g: 01 - Templatetitle 1 02 - Templatetitle 2 ... Thanks Link to comment Share on other sites More sharing options...
Robin S Posted November 24, 2017 Share Posted November 24, 2017 Try this in /site/ready.php $wire->addHookAfter('ProcessPageAdd::getAllowedTemplates', function(HookEvent $event) { // Get keys (IDs) of returned templates array $template_ids = array_keys($event->return); // Implode for use in a selector string $template_ids_str = implode('|', $template_ids); // Get TemplatesArray of those templates, sorted by label $templates = $this->templates->find("id=$template_ids_str, sort=label"); // Convert to plain array and return $event->return = $templates->getArray(); }); 4 2 Link to comment Share on other sites More sharing options...
ro-bo Posted November 24, 2017 Author Share Posted November 24, 2017 Hi Robin, thanks for your reply. I think it‘s exactly what I‘m looking for. I will try it in the next few days... Thanks, Robert 1 Link to comment Share on other sites More sharing options...
ro-bo Posted November 27, 2017 Author Share Posted November 27, 2017 Hi Robin. As expected, the sorting works perfectly now! Thanks, Robert 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