elabx Posted September 17, 2017 Share Posted September 17, 2017 Hi people! Is there a way to hook into the way the results of the admin search results are rendered? I'd love to make the links to the pages in the list go to the "view" page instead of the "edit" page specially in modules rendering a Process module. For example, look for the Fields page, and it will link you to edit the Field page. I've looked into the ProcessPageSearch module but can't find any javascript that renders the actual list, any clue? Thanks for further help! Link to comment Share on other sites More sharing options...
adrian Posted September 17, 2017 Share Posted September 17, 2017 $this->addHookAfter('ProcessPageSearch::executeFor You can see here: https://github.com/adrianbj/AdminRestrictBranch/blob/838858fd36a78df808b7690b4cddcb3a6c25ffa3/AdminRestrictBranch.module#L167-L180 where I have removed items from the search results, but you could easily use array_map to search and replace edit with view links in the returned array of matches. Hopefully this will help to get you going. 1 Link to comment Share on other sites More sharing options...
adrian Posted September 17, 2017 Share Posted September 17, 2017 @elabx - thought I'd take a quick look into what is actually required and this seems to work well: $this->addHookAfter('ProcessPageSearch::executeFor', function($event) { $response = $event->return; $responseArray = json_decode($response, true); $matches = $responseArray['matches']; $i=0; foreach($matches as $match) { if($match['type'] == 'Pages' && strpos($match['path'], $this->config->urls->admin) === false) $matches[$i]['editUrl'] = $match['path']; $i++; } $responseArray['matches'] = $matches; $event->return = json_encode($responseArray); }); Note that it only changes the link if the match has type of "Pages" and also doesn't point to an admin url. Let me know if this works at your end ok. 6 Link to comment Share on other sites More sharing options...
elabx Posted September 18, 2017 Author Share Posted September 18, 2017 Works great! Just added: $match["template"] == "admin" Because I didn't want normal "content" pages being modified. Thanks a lot for the help! 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