Jump to content

Php in tpl files?


Recommended Posts

I need to make one of the .tpl files print out some php code. I have read that Prestashop by default and for security reasons has turned off the ability to use {php} {/php}, so that is not the way. I know that it probably would be optimal to use smarty tags and the code inside the .php files and send it to the .tpl files. But i have no idea to use smarty. Maybe a simple example how to write some php code and make it print through the tpl file would be a solution.

 

Tnx :)

Link to comment
Share on other sites

  • 3 months later...

I tried the following but couldn't get inserting php inside a tpl template file able to work:

 

I create a test.php file with a simple

echo('Hello World!');

and placed it in my root directory.

 

At the end of my theme's footer.tpl I tried to add:

 

{ include file="../test.php" }

 

{ include file="http://domain.com/test.php" }

 

{ include_php file="../test.php" }

 

{ include_php file="http://domain.com/test.php" }

 

 

{php}
include('http://domain.com/test.php');}
{/php}

 

 

{php}
include('../test.php');}
{/php}

 

 

I even went into smarty.config.inc.php in the config folder and added

$smarty->allow_php_tag = true;

 

Any suggestions on what I could be doing wrong?

Edited by spiffyd (see edit history)
Link to comment
Share on other sites

  • 1 year later...

it's agains MVC model which is a part of idea of smarty and prestashop.

 

you can include tpl file from other .tpl file

but of course in "background" will be always some controller that handles first .tpl file

 

 

what you exactly trying to achieve?

Link to comment
Share on other sites

×
×
  • Create New...