Jump to content

Order of hooks for an increment number (solved)


mel47
 Share

Recommended Posts

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 :

  1. save an unpublished page via FormBuilder or via admin
  2. create an increment customized number (its : count-region). This number integrate some data contained in the page (region is filled after the page creation)
  3. 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

  • 2 weeks later...
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
});

 

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...