YoJoe Posted January 17, 2022 Share Posted January 17, 2022 I'm wondering how can I display a hook in template file using default method, but pass to it parameters to get the desired block. I have couple html blocks assigned to certain hooks, lets assume they stay within displayNav hook. They have automatically asigned ID during creation, and possible position value. What I'd like to achieve with {hook h='displayNav'} is to pass an ID or position value to get the desired html block. I don't know if default {hook} smarty constant allows to pass more paramaters than only hook name. Like for example {hook h='displayNav' id=1} or {hook h='displayNav' position=1} I was looking for such info or similar question but seems that I can't find the function responsible for it, and make an override or use builtin parameters. Anyone could enlighten me a bit? Link to comment Share on other sites More sharing options...
PepeFernandez Posted May 30 Share Posted May 30 Hello, a year later😅. Yes you can pass parameters like this, but to use the hooks you need to do it from some module, collect the parameters and return them in the template that is hooked to that hook. an example of your case: {hook h='displayNav' id=1 position=1} in your modulefile.php: public function install() { return parent::install() && $this->registerHook('displayNav'); } public function hookDisplayNav($params) { $this->smarty->assign(array( 'id' => $params['id'], 'position' => $params['position'] )); return $this->display(__file__, 'views/templates/hook/your-template.tpl'); } 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