J_Szwarga Posted February 28, 2020 Posted February 28, 2020 Trying to find a hook or some other method to change the page->editUrl based on it's template? If this requires using custom classes, I don't mind doing that either. Just trying to find a way to redirect from the normal admin page editor to an editor i have custom made in a module for pages using specific template.
Zeka Posted February 28, 2020 Posted February 28, 2020 Not sure that you can modify edit URL in hook, but you can definitely override it in inherited class. Or just add custom method via hook and use it $wire->addHook("Page(template=your_template)::customEditURL", function(HookEvent $event){ return //// }); 1
bernhard Posted February 29, 2020 Posted February 29, 2020 Interesting ? Yeah editUrl() is not hookable! Based on Zekas suggestion maybe something like this: $wire->addHook("Page::_editUrl", function(HookEvent $event) { $page = $event->object; switch($page->template) { case "home": $event->return = $this->pages->get(2)->url."my/custom/edit?id=$page"; break; default: $event->return = $page->editUrl(); } }); 1
J_Szwarga Posted March 20, 2020 Author Posted March 20, 2020 @bernhard thanks, yes I like your solution. Because then I can fallback to the built-in editUrl still in special cases when needed. 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