Hi, admins, I would like to request to move $this->extensions->hk_UpdateData($this, __FUNCTION__); above the processTemplate so the hook can be called before processTemplate or other functions. Thanks.
You do not need to move calls.
Just try to paste this inside your updateData hook
$var = $this->baseObject->view->getData('some_tpl_var_name');
$var .= 'hello world!';
$this->baseObject->view->assign('some_tpl_var_name', $var);
and you will see that you can change any variable inside your tpl.
Thanks abolabo. What if i want to change existing code and not the data's within the function?
Quote from: handoyo on December 08, 2015, 08:29:36 AM
Thanks abolabo. What if i want to change existing code and not the data's within the function?
you should not to change core code. it's a bad practice.
Just create your custom hook vars and add it into tpl.. Please read our docs about it.
http://docs.abantecart.com/pages/developer/template_customization_or_development_guide.html
Thanks, I understand it is a bad practice. It just in some situation the hook vars itself is not sufficient. And actually not replacinf the core code, But adding some more routines to it.
ic. also do not forget about core upgrades. To change code via hooks more safely because all code placed in your custom extension directory.
If you do not plan upgrade core - you can do anything you want :)
I do remember that, and that's why i asked abantecart to consider by adding hooks within the ValidateData function and on other hooks which i request it in my other post.
You can implement your own controller and completely replace the data in main controller with your hook.
Can you give an example of the code you need to change?
Quote from: handoyo on December 08, 2015, 12:06:37 PM
I do remember that, and that's why i asked abantecart to consider by adding hooks within the ValidateData function and on other hooks which i request it in my other post.
what core controller do you mean?
Hi abantecart and abolabo. I was trying to change the code in pages/sale/order/recalc. I'm trying to use custom order manager lib. I tried using hook init data, it works in ab v1.2.2 but not in 1.2.3-1.2.5. it gives me error: Fatal error: Call to a member function isLogged() on null in C:\xampp\htdocs\testing\t125\storefront\model\catalog\product.php on line 1149
.
Quote from: handoyo on December 09, 2015, 08:03:42 PM
Hi abantecart and abolabo. I was trying to change the code in pages/sale/order/recalc. I'm trying to use custom order manager lib. I tried using hook init data, it works in ab v1.2.2 but not in 1.2.3-1.2.5. it gives me error: Fatal error: Call to a member function isLogged() on null in C:\xampp\htdocs\testing\t125\storefront\model\catalog\product.php on line 1149
.
i guess you got this error on admin side. Add check for admin (i mean if(IS_ADMIN!==true)) before isLogged() func call.
Abantecart have two models with rt catalog/product, on admin and sf.
Yes Abolabo, I get that error on admin side. I didn't hook or use is logged in function.
Quote from: handoyo on December 10, 2015, 07:58:12 AM
I didn't hook or use is logged in function.
it's a model rt collision.
Your error is in $this->customer->isLogged() call but $this->customer object not exists for admin side. Check your hooks.
Thanks abolabo, I will check it. Btw is it correct to use the extended orderanager lib im initdata instead of updateData? If I use it in updateData I didn't get the error message.
Quote from: handoyo on December 10, 2015, 09:32:29 AM
Thanks abolabo, I will check it. Btw is it correct to use the extended orderanager lib im initdata instead of updateData? If I use it in updateData I didn't get the error message.
it depends on data process. Usually you send some data with POST request and core controller validate and save it. If data is valid - page send redirect to the this controller but as GET request. _UpdateData will no call in that case. If you want to validate data the best way do this inside InitData.. ( or validateData if you can)
Hi abolabo, I suppose validateData is usable if there is as hk_validateData function within the controller, isn't it?
yes. but it can be also in models too.
we plan to add more calls in our models.
That would be great. Please consider to add in the customer account, address model and admin add customer account, address model too.