Neeks Posted March 6, 2015 Posted March 6, 2015 Looking to hook into creating a new page after the new page has a $page->id. Any one know what the correct hook might be? public function init(){ $this->pages->addHookAfter('????', $this, 'myHookFunction'); } Once I have the correct hook does any one know I can access the $newPage->id ? public function myHookFunction(HookEvent $event){ $newPage = $event->arguments[0]; //would this be correct? $this->error('it worked here is the id of your new page:'.$newPage->id); } I might be able to jerry-rig it, if there is no hook, by hooking to save function, and comparing creation date with current date or something less elegant....I'm open to better and maybe less creative ways of solving this problem ;-)
adrian Posted March 7, 2015 Posted March 7, 2015 This is what you are looking for: $this->pages->addHookAfter('added', $this, 'hookAdded'); public function hookAdded(HookEvent $event){ $newPage = $event->arguments[0]; $this->message('it worked here is the id of your new page:'.$newPage->id); // Yes, this will work } 4
Neeks Posted March 9, 2015 Author Posted March 9, 2015 It's always more simple then I expect. Thanks Adrian.
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