itps Posted September 23, 2013 Share Posted September 23, 2013 How can i pass parameters to module hook function. For example i have a hook displayCarrierExtraInfo which must display some extra info if carrier id=2 In theme template I call hook like this: foreach $option.carrier_list as $carrier}<div class="delivery_option_title">{$carrier.instance->name}</div>{hook h='displayCarrierExtraInfo'}{/foreach} In module i have function function hookDisplayCarrierExtraInfo($params){return 'some extra info';} Currently in $params are all smarty and other variables but in this case I need only get carrier id what is in active template carrier loop. How can i pass in template carrier id or some other parameters to hook function? Link to comment Share on other sites More sharing options...
itps Posted September 24, 2013 Author Share Posted September 24, 2013 can somebody help me with this? i am stuck with this problem Link to comment Share on other sites More sharing options...
Enrique Gómez Posted September 24, 2013 Share Posted September 24, 2013 Maybe your objective must be achieved without the use of hooks. which must display some extra info if carrier id=2 It seems like you can put some smarty code instead of {hook h='displayCarrierExtraInfo'} to test if the carrier id = 2 I think the use of display hooks is that you have some place in the tpl where different modules registers to add their output. So for example when rendering product.tpl the controller does 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), And then every module registered will have their hookDisplay.. method called (in this case you can see the product is passed also as parameter). The result of this method will be put in the product.tpl (you have a module order, the first,the second..etc) {if isset($accessories) AND $accessories}<li><a href="#idTab4">{l s='Accessories'}</a></li>{/if} {if isset($product) && $product->customizable}<li><a href="#idTab10">{l s='Product customization'}</a></li>{/if} {$HOOK_PRODUCT_TAB} </ul> <div id="more_info_sheets" class="sheets align_justify"> Link to comment Share on other sites More sharing options...
Enrique Gómez Posted September 24, 2013 Share Posted September 24, 2013 (edited) Anyway you can pass parameters like this example I've found {hook h="displayAdminCustomers" id_customer=$customer->id} So in the hookDisplayAdminCustomers($params) you can access $params['id_customer'] Edited September 24, 2013 by Enrique Gómez (see edit history) 12 1 Link to comment Share on other sites More sharing options...
iztok Posted June 21, 2014 Share Posted June 21, 2014 You rock, just what i was looking for! Link to comment Share on other sites More sharing options...
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