AbanteCart Community
AbanteCart Development => Development Help Needed => Topic started by: yonghan on June 26, 2014, 07:13:03 AM
-
Hi,i would like to ask if it's possible to hook functions in controller?i.e i would like to extend add function in customer manage address controller to use other styles.insted of directly edit the controller or using javascript.thanks a lot.
-
You can hook to any controller in the beginning and at the end. You can also have pre and post controllers
Check this manual:
http://www.abantecart.com/document_wiki/index.php/AbanteCart_Extension’s_Developer_Guide#Hooks
-
Hi,i would like to ask if it's possible to hook functions in controller?i.e i would like to extend add function in customer manage address controller to use other styles.insted of directly edit the controller or using javascript.thanks a lot.
of cource.
read this first
http://www.abantecart.com/document_wiki/index.php/AbanteCart_Extension%E2%80%99s_Developer_Guide#Hooks (http://www.abantecart.com/document_wiki/index.php/AbanteCart_Extension%E2%80%99s_Developer_Guide#Hooks)
and also you can open some extension's file with hooks for ex. default_pp_pro/core/default_pp_pro.php to look...
Also we have developer tools to generate extension https://github.com/abantecart/developer_tools_extension (https://github.com/abantecart/developer_tools_extension)
You can build your own extension very fast.
-
Thanks a lot for the replies,i'll take a look at the pre and post controller example from existing extensions.
-
Hi abolabo,my question is not clear enough.What i would like to do is hook function i.e insert function in storefront/controller/pages/account/address.Is it possible to do that?Thanks
-
every method of core-controller contain 2 hook calls:
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
and
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
You just should to add methods
public function onControllerPagesAccountAddress_InitData(){
//write your code here
}
and
public function onControllerPagesAccountAddress_UpdateData(){
//write your code here
}
-
I've tried using Update_Data() to hook before,but when i run the code,the rest of the core function didn't work.
-
I've tried using Update_Data() to hook before,but when i run the code,the rest of the core function didn't work.
i guess you call hook on all methods on core-controller.
use condition if($this->baseObject_method='name of method') to define place when your hook must work
-
I will try it again,thanks a lot.