Jump to content

Display a php variable in a tpl file with smarty


Recommended Posts

Hi, this is my first time creating a module for prestashop and i'm stuck with sending a php variable to the tpl file.

I'm using smarty for sending that variable but when i upload the module nothing get diplyed:

What i did wrong? You have an idea?

Thanks for your time and helps;

my regards.

Here i wrote down the code of it.

In php file:

public function test($params){

    $smarty= new smarty();

    $test='<h1>TEST</h1>';

    $smarty->assign('TS',$test);

    $smarty->display('newmod.tpl');

}

In tpl file:

<div id="mymodule_block_home" class="block">
  <div class="block_content">    
    <div>
        {$TS}
    </div>
  </div>    
</div>

Edited by PietroSAIinformatica
Miss wrote the code in the tpl file part (see edit history)
Link to comment
Share on other sites

4 hours ago, JBW said:

You named the Smarty variable as 'TS', so you have to access it in smarty as {$TS}

yeah sorry i inverted them but even in the right way it gaves me problem. 

I was pretty sure about it but i checked and the results are the same.

Thank you for pointing out this error i edit the topic now and correct it

Edited by PietroSAIinformatica (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...