VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Coding Central => Topic started by: alexxsav on June 04, 2014, 14:00:09 PM

Title: How to sent manual variable to loadTemplate
Post by: alexxsav on June 04, 2014, 14:00:09 PM
Hello.

I have some customization in product.tpl. I add manual variable and want to use it in other template file. I input this template file like: $this->loadTemplate('customtemplate');
But i cant get access to this variable, and have to write creation again - its not useful.
Any advise?
Title: Re: How to sent manual variable to loadTemplate
Post by: byPV on June 06, 2014, 11:28:35 AM
Hi,

if you assign the variable into $this->{variable} then you can access to this value from another templates.

Regards,
Pavel
Title: Re: How to sent manual variable to loadTemplate
Post by: alexxsav on June 10, 2014, 10:36:22 AM
Thanks^ but can you explain what you mean?
Title: Re: How to sent manual variable to loadTemplate
Post by: byPV on June 10, 2014, 11:40:59 AM
Hi,

If I understand properly, this code in a template will help you:


...
...
$this->your_variable = 'some value';
...
$this->loadTemplate('customtemplate');
...
...


In the customtemplate you can access to the variable by way:


...
...
echo $this->your_variable;
...
...


Regards,
Pavel