Jump to content

adding PHP code to a .tpl


Recommended Posts

I would like to add a php code (with the <?php ?> tags) to a .tpl file (such as editorial.tpl and blockadvertising.tpl) in order to add openx banners.
simply adding the php code and the tags doesn't work,
how can it be done?

Link to comment
Share on other sites

Hi bsphere,

I'm not sure whether it is possible to add PHP code to TPL files, but it shouldn't be. You should instead put it in the appropriate PHP file, then pass the results of the PHP into the TPL file.

For example, in the PHP file:

$output = phpfunction();
$smarty->assign('output', $output);
$smarty->display(_PS_THEME_DIR_.'template.tpl');



Then in the TPL file, simply put the following code wherever you want to put the PHP:

{$output}

Link to comment
Share on other sites

  • 1 year later...
Hi bsphere,

I'm not sure whether it is possible to add PHP code to TPL files, but it shouldn't be. You should instead put it in the appropriate PHP file, then pass the results of the PHP into the TPL file.

For example, in the PHP file:

$output = phpfunction();
$smarty->assign('output', $output);
$smarty->display(_PS_THEME_DIR_.'template.tpl');



Then in the TPL file, simply put the following code wherever you want to put the PHP:

{$output}



I am still getting error 500 in second line: $smarty->assign('output', $output);
I assign to output numerical value from some php function but still getting error.
Link to comment
Share on other sites

×
×
  • Create New...