我有Smarty模板文件。当从Smarty传递到php时,$ listing.activation_date为null。任何解决方案将smarty var传递给php
{$listing.activation_date}
{php}
$startDate = strtotime('now');
$interval = $startDate - strtotime($this->get_template_vars('$listing.activation_date'));
{$listing.activation_date} = 2012-Sep-05
我已经改变了$ Smarty的,以$是为了防止非对象错误。
$this->assign("interval", $interval);
$days = floor($this/ (60 * 60 * 24)); {/php}
{if $days < 1} <img src=" {$GLOBALS.site_url}/templates/Natural/main/images/new.gif"/>
{/if}
在{php}中是$天,然后在Smarty中是$天< 1?
Smarty用于表示。在“常规”php脚本中进行所有计算,并将计算出的值传递给Smarty。这是(在我看来)使用模板引擎的正确方法。 –