dev123 Posted March 24, 2014 Share Posted March 24, 2014 public static function getModuleInfo() { return array( 'title' => 'Hello World', 'version' => 101, 'summary' => 'An example module used for demonstration purposes. See the /site/modules/Helloworld.module file for details.', 'href' => 'http://www.processwire.com', 'singular' => true, 'autoload' => true, ); } public function init() { $this->pages->addHookAfter('trash', $this, 'example5'); } public function example5($event){ $this->message("TRASHed"); } I just edited helloworld module to add hook after trash ...I have succesfully added hook after save, but this after trash hook doesnt seem to work for me . Pls guide where am i goin wrong . What happens is when i delete a page(added to trash), this message "TRASHed " appears twice as in the snapshot. Link to comment Share on other sites More sharing options...
dev123 Posted March 26, 2014 Author Share Posted March 26, 2014 <?php class Helloworld extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Hello World', 'version' => 101, 'summary' => 'An example module used for demonstration purposes. See the /site/modules/Helloworld.module file for details.', 'href' => 'http://www.processwire.com', 'singular' => true, 'autoload' => true, ); } public function init() { $this->pages->addHookBefore('trash', $this, 'example5'); } public function example5($event){ if ($this->skipme) return; $this->message("TRASHed"); $this->skipme=true; } For some reason this example 5 function was running twice on trashing one page ...So this solved my problem .But i still dont get it why is it running twice Link to comment Share on other sites More sharing options...
Soma Posted March 31, 2014 Share Posted March 31, 2014 I'm not sure, but it may doing something when trashing a page and save that page again so it ends up in trash. Very likely. Your solution is perfect to go. But maybe you can aslo just use the Pages::trashed instead as this would be just once after the page is trashed. 1 Link to comment Share on other sites More sharing options...
Soma Posted April 2, 2014 Share Posted April 2, 2014 This is also wrong board. 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