johnnydoe Posted February 7, 2023 Share Posted February 7, 2023 Hi folks, is it possible to sort the results of the admin search in PW - in my case just by title of the page? I think by default it is sorted by it's position in the page tree? I tried to inidicate a sorting for the children of the page "Admin" > "Pages" > "Search", but without success. Also the "Page Search" module, found in the core modules doesn't seem to have a sort option for the results. Can anyone help me? Thank you very much in advance! Jonas Link to comment Share on other sites More sharing options...
zoeck Posted February 7, 2023 Share Posted February 7, 2023 You can use a hook for this ? 1 Link to comment Share on other sites More sharing options...
johnnydoe Posted February 7, 2023 Author Share Posted February 7, 2023 Thank you very much! This works very well for the first result page! But if I click on "View > All pages", which takes me to the detailed search results page, the results are not in alphabetical order... can I hook this too? Off-topic question: how can I find which hook can I use where, or do I just need common sense and and maybe guessing to find the right hook? ? Link to comment Share on other sites More sharing options...
zoeck Posted February 7, 2023 Share Posted February 7, 2023 You have too hook the Lister: $wire->addHookBefore('ProcessPageLister::execute', function(HookEvent $event) { /* @var ProcessPageLister $lister */ $lister = $event->object; // I'm not sure, but the parent of the "Search Lister" has the ID 0? if($lister->parent->id !== 0) return; // Set sort $lister->defaultSort = 'title'; bd("Changed Search Sort"); }); 1 Link to comment Share on other sites More sharing options...
Jan Romero Posted February 7, 2023 Share Posted February 7, 2023 1 hour ago, johnnydoe said: if I click on "View > All pages", which takes me to the detailed search results page, the results are not in alphabetical order... IIRC this just takes you to the normal page finder, where you can click the column headers to sort. You can also add and remove columns if the one you’re looking for isn’t there by default. 1 Link to comment Share on other sites More sharing options...
johnnydoe Posted February 7, 2023 Author Share Posted February 7, 2023 Hi @Jan Romero, you are so right, I missed that... that is a very good and simple to sort the results, thank you! ... and @zoeck: that is a great way to sort the results by default, the code works like a charm. Thanks again! ❤️ 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