Jump to content

Use module in all template


Skayfer

Recommended Posts

Hi,

 

I make my module with own text field. In conf page i have 3 text input, and in module .tpl i can use it., but now, i would like can use variables and function from my module in all template. My module should be availability like front controller.

 

Maybe i need make function in my module that can copy code to front controller ?

 

Thanks for answers.

 

 

Link to comment
Share on other sites

so you mean is you want to get value from 3 inputs, then use them in all template files?

you can do it:

- hook to displayHeader

- in this hook use $this->context->smarty->assign for send variables to template, so you can use there variables for any TPL file in template because this is global.

remember us $this->context->smarty->assign 

NOT $this->smarty->assign

Link to comment
Share on other sites

Hi taydotech :)

 

Maybe it have sense.

 

Before i only write something in front controller (function) and result print with 'echo'. In template i use

{FrontController::function123()}

or write module,  create variable with hook function

'var' => Configuration::get('VAR'),

, but second way work only in module template.

 

I make what you say, add module to hook header, but what is next ? I still can't use variables outside module template. Now i can only make separate function for each variable ? How can i display result this function ? And how you taydotech display function results ? With echo ?

 

Thanks for answer and patience :)

 

 

PS

 

 

I used excatly in left hook function

$this->context->smarty->assign(     array(
         'my_module_name' => Configuration::get('MYMODULE_NAME'),
)
);
 
but i can use it only in my module tpl, i cant use it for example in block categories in left column.
 
 
 
PS2
 
 
I have below 
 
return $this->display(__FILE__, 'mymodule.tpl');

maybe this restrict display my variables ?

Edited by Skayfer (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...