Zeka Posted January 16, 2020 Share Posted January 16, 2020 Hi. Hi. By default when you delete a page from delete tab on page edit screen it redirects to URL like 'admin/page/?open=1033' where 1033 is ID of the parent of deleted page. I'm using a custom process module for managing news pages, so I want to redirect to my custom trash page. This URL is hardcoded in ProcessPageEdit module https://github.com/processwire/processwire/blob/master/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module#L2434 AFAICS the only way to change it is to hook ProcessPageEdit::buildFormDelete, remove default checkbox, add custom one and then hook to ProcessPageEdit::processInput, execute custom delete function. Is it? Maybe there is easier way? Link to comment Share on other sites More sharing options...
Robin S Posted January 16, 2020 Share Posted January 16, 2020 You can hook Session::redirect and check the redirect URL and the current process. Not perfect, but as far as I can see the deletePage() method uses a redirect URL that is unique in ProcessPageEdit and is therefore identifiable as coming from that method. $wire->addHookBefore('Session::redirect', function(HookEvent $event) { $url = $event->arguments(0); if($this->process == 'ProcessPageEdit') { $admin_url = $event->wire('config')->urls->admin; if(strpos($url, $admin_url . 'page/?open=') === 0) { $event->arguments(0, '/your/custom/url/'); } } }); 1 Link to comment Share on other sites More sharing options...
Zeka Posted January 16, 2020 Author Share Posted January 16, 2020 @Robin S Thanks. For now, I ended up with .... $this->wire()->addHookAfter('Pages::trashed(template=link-block|post|tag)', $this, 'customRedirectOnDelete'); public function hookRedirectOnLinkBlockDelete($event) { $event->wire()->addHookBefore('Session::redirect', function(HookEvent $event) { $url = $event->arguments(0); if($this->process == 'ProcessPageEdit') { $admin_url = $event->wire('config')->urls->admin; if(strpos($url, $admin_url . 'page/?open=') === 0) { $event->arguments(0, '../trash/'); } } }); } 2 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