Reputation: 1051
In prestashop, i am in need to pass the output value stored in a variable of a php file to a template file within my modules folder.How to pass the smarty variable resultstring output to my template fie.
php code
<?php
$output = "welcome";
$smarty->assign('resultstring', $output);
?>
template file code
{if $resultstring == 'welcome'}
<h6>Hai welcome</h6>
{else}
<h6>not exist </h6>
{/if}
Upvotes: 0
Views: 4073
Reputation: 5067
I am also a beginner in Prestashop, but why not to intervene maybe I can give help.
I think you need to create a controller inside of your php file (that you should locate in the root of your module folder), something like:
<?php
class displayController extends ModuleFrontController
{
$output = "welcome";
$this->context->smarty->assign('resultstring', $output);
public function initContent()
{
parent::initContent();
$this->setTemplate('template.tpl');
}
}
You can keep the template file as it is.
Upvotes: 1