Jump to content

New hooks in 1.5


Recommended Posts

Hi Fabien,

 

I would love 4 new hooks :

- when you enter the shipping number in the order page (AdminOrders.php => process)

- when you send the mail with the new password on password recovery (PasswordControllerCore.php => process)

- when a customer send a message using the contact form (ContactFormControllerCore.php => preProcess)

- in the mailalert module, when a product is available again, and you send the email to customer (mailalert.php => sendCustomerAlert)

 

I need all of them because i send all these information by SMS with my sendsms module. But i'm sure it can be usefull for someone else ;)

Link to comment
Share on other sites

Hi Patanock,

 

Yours hooks seems ok to me except the one of recovery password. I will talk about it with the team and come back to you.

 

 

Hi Kalyrock,

 

I'm okay for the hook in AdminCategory.

Do you want me to fix the bug reported on the forge or do you mean you want me to add a hook in the blocktopmenu.tpl ?

Link to comment
Share on other sites

Hi Patanock,

 

Yours hooks seems ok to me except the one of recovery password. I will talk about it with the team and come back to you.

 

 

Hi Kalyrock,

 

I'm okay for the hook in AdminCategory.

Do you want me to fix the bug reported on the forge or do you mean you want me to add a hook in the blocktopmenu.tpl ?

 

 

Hi,

Just add a hook horizontal nav and change the html in blockmenu.tpl. This will fix the bug.

thx

Link to comment
Share on other sites

Hi Raphael,

 

Please fix the bug reported by kalyrock.com http://forge.prestashop.com/browse/PSFV-399 which is assigned to you and take care of your rabbit =)

 

Hi Kalyrock,

 

Raphael will take care of the bug but adding a hook in a module, I'm not sure I see the interest :X

Hooks permits develop to add / change functionalities without editing core file. Here you can duplicate the module, give a new name to it, and change its functionnement. Or did I miss something ?

Link to comment
Share on other sites

Hi Raphael,

 

Please fix the bug reported by kalyrock.com http://forge.prestas...browse/PSFV-399 which is assigned to you and take care of your rabbit =)

 

Hi Kalyrock,

 

Raphael will take care of the bug but adding a hook in a module, I'm not sure I see the interest :X

Hooks permits develop to add / change functionalities without editing core file. Here you can duplicate the module, give a new name to it, and change its functionnement. Or did I miss something ?

 

Currently, there is just one hook in the header of the page (not in the module): hook top. It ll be usefull to have a second hook (ex : nav horizontal).

Link to comment
Share on other sites

Hi,

 

I added new hooks, amongst it, there were some hooks you asked for :

- actionAdminOrdersTrackingNumberUpdate

- actionPasswordRenew

- actionModuleMailAlertSendCustomer

- displayAdminCategoriesForm

 

I just commited them, I'll let you test :)

 

@Patanock

I'm not sure for this one

"when a customer send a message using the contact form (ContactFormControllerCore.php => preProcess)", I think you meant ContactController.php, where in the code do you need a hook ?

 

@Phrasespot

"A hook in the overriden update method of Customer class: postCustomerUpdate" Why ? This method call parent::update and there already are hooks in ObjectModel before and after update.

 

@PrestaMax, do not worry, I will make one !

Link to comment
Share on other sites

@Phrasespot

"A hook in the overriden update method of Customer class: postCustomerUpdate" Why ? This method call parent::update and there already are hooks in ObjectModel before and after update.

Yep, I noticed and modified the post but obviously you caught it before the modification :)

Link to comment
Share on other sites

Hello,

 

Add a hook for hotizontal nav. Currently in the new theme, one div is open in header.tpl and close in blocktopmenu.tpl (module).(cf http://forge.prestas...browse/PSFV-399)

Hook Admincategory for adding a tab in the page add category

 

I would second this. If the top nav had it's own hook there would be more styling options. Currently you are dependent on the closing div in the top nav module to place it outside of the header right area. No chance to put the horizontal nav in a separate container (for example if you want to extend the navbar across the entire width of the screen). This would require modification of the top nav module. If the top nav had it's own hook this won't be a problem at all.

 

The horizontal nav simply doesn't belong in the top right header area where the current hook is placed. A navigation usually needs a full page width and putting any closing divs in the top nav module in order to get it placed correctly is not very satisfying.

Link to comment
Share on other sites

Will there be a hook or similar to be able to add custom customer registration fields to the checkout process, as well as remove them?

 

I realise this is possible at the moment but it's tricky. Really the only fields that I'd think are required by the system would be username/password (digital download only stores)?

 

Thanks,

 

Mark

Link to comment
Share on other sites

  • 1 month later...

Hi Mark,

A hook in registration form will not permit you to remove fields, only add some.

I will add a hook for this.

 

Hi Ivoire,

Yes, you can add a hook in a module. I will document this part.

 

Hi Phrasespot,

I will add one.

 

Hi Pixeles,

I added many many hooks, all describing here will be very long.

I'll make a documentation about it.

 

Best regards,

Link to comment
Share on other sites

Hi Mark,

A hook in registration form will not permit you to remove fields, only add some.

I will add a hook for this.

 

Hi Ivoire,

Yes, you can add a hook in a module. I will document this part.

 

Hi Phrasespot,

I will add one.

 

Hi Pixeles,

I added many many hooks, all describing here will be very long.

I'll make a documentation about it.

 

Best regards,

Brilliant, thanks Fabien :)

Link to comment
Share on other sites

Hi,

it could be very useful an hook related with the end of a new order status assignment. Currently there are two hooks in this area but they're not able to be related with the new order status (the first hook is raised before the status is changed, the second one during the order status updates). Currently, using these hooks it's not possible to analyze the "new status" and if necessary to assign a new one because after the hook execution the OrderHistory is updated with the "old" order history status.

 

Think in this way. If the new order status is "AAA" then, after some checks, I would like to move the order to the status BBB. At the end, currently the last order status will still be AAA and not my BBB properly added to order history using the API.

 

Regards,

Link to comment
Share on other sites

Hi Ivoire,

Yes, you can add a hook in a module. I will document this part.

 

It would be great if you could say in a nutshell until the documentation is ready, is it possible to add our own hooks from modules in any other way than copying files in the Override folder?

Link to comment
Share on other sites

To add a hook in a module, just use the Hook ObjectModel to save it in database. What is complicated ?

 

I want to add hooks to the existent Prestashop classes and controllers from my module and my question is if there is possible way to do it without copying files to override folder.

Link to comment
Share on other sites

To add a hook in a module, just use the Hook ObjectModel to save it in database. What is complicated ?

It is not complicated but Hook class does not expose any of its fields like other subclasses of ObjctModel so you cannot do something like:

 

$h = new Hook();
$h->name = '...';
$h->title = '..';
$h->description = '...';
...
$h->save();

 

One has to operate on DB directly to add a hook (with all the fields populated).

Link to comment
Share on other sites

And what about this ?

 

class SaveableHook extends HookCore {
   public $description;
   public $title;
   protected $fieldsRequired = array('name', 'description', 'title');
   public function getFields()
   {
    $fields = parent::getFields(); 
    $fields['description'] = pSQL($this->description);
    $fields['title'] = pSQL($this->title);
    return $fields;
   }
}

 

Not tested :ph34r:

Link to comment
Share on other sites

  • 2 weeks later...

I'm not sure what you are trying to do guys, but in 1.5 you do not need to make manual insertion for hooks anymore.

 

Hi Fabien,

 

I got an idea, maybe it's too much to implement in 1.5, but I was thinking like this.

 

1. Add a hook in "init", make it possible to use a global variable here, lets call it $getConfigurations array.

2. Then in the modules, we hook them to init and populate this array with the configuration values we need, like say $getConfiguration[] = 'PS_SHOP_NAME';

3. in the init function, you then do a Configuration::getMultiple with all values from getConfiguration array and store this in a global variable like say $shopConfiguration['PS_SHOP_NAME'].

 

this can then be accessed from all modules and even from the pages controllers, this should remove many of the dupliacate Configuration::get and the need for modules to make extra selects from the database. I think this would speed up Prestashop a bit. What do you think?

Link to comment
Share on other sites

  • 2 weeks later...

Hmm not?

 

Ex :

 

if ($this->context->getMobileDevice() == false)
       {
           $this->context->smarty->assign(array(
               'HOOK_HEADER' => Hook::exec('displayHeader'),
               'HOOK_NEW' => Hook::exec('myNewBlock'),
               'HOOK_TOP' => Hook::exec('displayTop'),
               'HOOK_LEFT_COLUMN' => ($this->display_column_left ? Hook::exec('displayLeftColumn') : ''),
               'HOOK_RIGHT_COLUMN' => ($this->display_column_right ? Hook::exec('displayRightColumn', array('cart' => $this->context->cart)) : ''),
               'currentController' => get_class($this->context->controller),
           ));
       }
       else
       {
           $this->context->smarty->assign(array(
               'HOOK_MOBILE_HEADER' => Hook::exec('displayMobileHeader'),
               'currentController' => get_class($this->context->controller),
           ));
       }

Link to comment
Share on other sites

Now you can execute a hook directly in your tpl by writing this {hook h='nameOfYourHook'}

You don't need anymore to override, and I understand that these lines are confusing because they don't respect the last standard of 1.5). We should / will change these lines.

Link to comment
Share on other sites

  • 2 weeks later...

Now you can execute a hook directly in your tpl by writing this {hook h='nameOfYourHook'}

You don't need anymore to override, and I understand that these lines are confusing because they don't respect the last standard of 1.5). We should / will change these lines.

 

Hi Fabien. This trick don't work for me.

In Install function of module I added a line: $this->registerHook('layeredNav')

In the back office I transplanted my module to this hook "layeredNav"

and in tpl file i added a line: {hook h='layeredNav'}

but my module don't appeared in needed place.

P.S. sorry for my bad english)

Link to comment
Share on other sites

  • 1 month later...

Hello,

Anybody can explain me how to add a new Hook in 1.5 ? I want to hook center content on a few pages.

I tried the 1.4 method but not works, I spent a lot of time searching through the forums and more but did not find...

Thanks.

Link to comment
Share on other sites

Hi,

 

thank you for this information - it's easy now, to insert own hooks with {hook h='nameOfYourHook'}.

 

Is there any other way to enable own hooks in modules? To enable a hook for a module, this code in the module is nessesary, right?

 

public function nameOfYourHook($params)
{
	return $this->hooksomeDefaultHook($params);
}

 

Is ist possible to override the php-class or better an extra config-file / settings to enable hooks for modules. Maybe a part in the theme config.xml like:

 

<hooks>
  <blocksearch available="nameOfYourHook" />
</hooks>

 

That would be a nice function and better for module-updates... :)

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

 

I added new hooks, amongst it, there were some hooks you asked for :

- actionAdminOrdersTrackingNumberUpdate

- actionPasswordRenew

- actionModuleMailAlertSendCustomer

- displayAdminCategoriesForm

 

I just commited them, I'll let you test :)

 

Hi, where are these hooks ? I don't find them... :-/

Link to comment
Share on other sites

×
×
  • Create New...