Jump to content

Accessing variable from HOOK file


stinkytofu
 Share

Recommended Posts

I am having trouble with the following issue... in the main.tpl template file, I have the following code:

{assign var="promoText" value='Summary'}
{$HOOK_PROMO}

Then in the promo.tpl file, which contains all the code for HOOK_PROMO, I try to access and display the $promoText variable as follows:

{$promoText}



The problem is that the promo.tpl hook file cannot access the $promoText variable declared in the main.tpl template file. Any idea how I can make the $promoText file available inside the HOOK_PROMO include file in PrestaShop?

Many thanks!

Share this post


Link to post
Share on other sites

Anybody?

This is the reason why I dislike Smarty and other templating systems. Why force the programmer to learn a whole new scripting language to code, when PHP is quite adequate as a scripting language? If I could use PHP code directly inside the templates, then this issue would be moot.

Share this post


Link to post
Share on other sites

You're doing it the wrong way. If you want to call a TPL from another TPL file and pass in a variable, you should use code like the following:

{include file='promo.tpl' promoText='Summary'}



By the way, you can use PHP code in a TPL file. Just use the {php} tag. See here for more information.

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More