kreativmonkey Posted July 7, 2016 Share Posted July 7, 2016 I'm working on a notification Module that hooks into Page::saveReady . Then i will check if a page is New, Changed or Deleted to notify with different text and filter the right template. I'm working on a notification Module that hooks into Page::saveReady . Then i will check if a page is New, Changed or Deleted to notify with different text and filter the right template. public function hookPageSave(HookEvent $event){ $page = $event->arguments[0]; $template = $page->template; $templates = $this->notificationChange; // if page have no id => return if(!$page->id || !$page->title) return; // Check if page is Deleted if($page->isTrash()){ if(!in_array($template->name, $this->notificationDelete)) return; $this->log->save('debug', "Page is Deleted: $page->title"); //$this->hookPageDelete($event); return; } if($page->isNew()){ if(!in_array($template->name, $this->notificationPublish)) return; $this->log->save('debug', "New Page: $page->title"); return; } // Check if page is Changed if($page->isChanged() && !$page->isNew()){ if(!in_array($template->name, $this->notificationChange)) return; $this->log->save('debug', "Page Changed: $page->title"); //$this->hookPageChange($event); return; } i create a new post and if i publish this post i've got false on the $page->isNew() call. I worked around a little bit but i don't know how i can find out if a page is new ore just changed. For trigger changes i must change the hook to Page::saveReady (from Page::saved) but what do i need to trigger if the page is new? Link to comment Share on other sites More sharing options...
LostKobrakai Posted July 7, 2016 Share Posted July 7, 2016 isNew() will only be true, if a page was never saved to the db, which in terms of backend creation of pages is only till after the page add screen, where you put in the title/name of a page. Link to comment Share on other sites More sharing options...
kreativmonkey Posted July 8, 2016 Author Share Posted July 8, 2016 thanks for your answere. So i'm looking to do other logic for my module, thanks. 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