Write Php code in tpl

Hi i installed the latest OJS version
but i couldn’t write a simple echo php function in tpl !
and i dont know how can i do that ?!

My simple code is:
$description = $this->get_template_vars(‘description’);
$length =strlen($description);
$dtts = ($length>250)?’ …’:"";
echo nl2br(substr($description,0,280).$dtts);
in the last version i used like this in my tpl file
{php}
$description = $this->get_template_vars(‘description’);
$length =strlen($description);
$dtts = ($length>250)?’ …’:"";
echo nl2br(substr($description,0,280).$dtts);
{/php}

Thanks in advance

Hi @mbabaei,

The latest version of OJS uses Smarty 3+ in which php tags aren’t supported anymore. If you want make custom templates I suggest to make yourself familiar with Smarty documentation: https://www.smarty.net/ Apart from Smarty, I worked with other template engines and they all are pretty similar. For debugging you can use, e.g., {$var|@var_dump}.

@Vitaliy Hi
I am familiar with Smarty 3+
and i just want to know is there anyway to write php code in tpl or not !
so i got my answer

Thanks a lot

1 Like