mel47 Posted January 3, 2018 Share Posted January 3, 2018 Hi, Help; I'm lost with hooks. Basically all my code works, but I just don't know under which hook I should put it. I need : save an unpublished page via FormBuilder or via admin create an increment customized number (its : count-region). This number integrate some data contained in the page (region is filled after the page creation) Increment the count. For each region, I have a field called "increment". I have problem with "SavePage" since the region is not filled after adding the page and it give error on increment of the count. Same problem with SaveReady. What else I could use? Or in which order? The increment should be before or after save? Before or after the number creation? Thanks Link to comment Share on other sites More sharing options...
mel47 Posted January 12, 2018 Author Share Posted January 12, 2018 Hi, I'm still fighting with this issue. Does it exist a hook that run on each pagesave (saveReady) EXCEPT on the creation of the page? Thanks Link to comment Share on other sites More sharing options...
Robin S Posted January 12, 2018 Share Posted January 12, 2018 49 minutes ago, mel47 said: Does it exist a hook that run on each pagesave (saveReady) EXCEPT on the creation of the page? $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if(!$page->id) return; // Page ID is 0 when page is first created // Your code here }); 3 1 Link to comment Share on other sites More sharing options...
mel47 Posted January 15, 2018 Author Share Posted January 15, 2018 Oh, so simple, but so efficient. 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