mel47 Posted January 3, 2018 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
mel47 Posted January 12, 2018 Author 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
Robin S Posted January 12, 2018 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
mel47 Posted January 15, 2018 Author Posted January 15, 2018 Oh, so simple, but so efficient. Thanks!!
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