Jump to content

Hooks for modifying page->editUrl


J_Szwarga
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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 ////
});

 

  • Like 1
Link to comment
Share on other sites

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();
  }
});

Nig2QHy.png

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...