关闭

PHP中Smarty引擎的常用语法

标签: phpsmarty
295人阅读 评论(0) 收藏 举报
分类:

PHP中Smarty引擎的常用语法

输出今天的日期:

{$smarty.now|date_format:"%H:%M %A, %B %e, %Y"}

实际上用到了PHP的time()函数

明天Date of Tomorrow:

{"tomorrow"|date_format:"%A, %B %e, %Y"}

后天Date of the day after tomorrow (Day+2):

{"+2 days"|date_format:"%A, %B %e, %Y"}

(Day+3):

{"+3 days"|date_format:"%A, %B %e, %Y"}

相关链接:

How to do to print out date of tomorrow (day+1) with Smarty? - v1.x Store Design & Templates - CS-Cart Community Forums http://forum.cs-cart.com/topic/8070-how-to-do-to-print-out-date-of-tomorrow-day1-with-smarty/

foreach

    {foreach from=$workDetails key=key item=workDetail}
        <td>{$workDetail['name']}</td>
    {/foreach}

if, else

{if $weekDay neq 0 and  $weekDay neq 6}

{else}

{/if}

调用php函数

{$monthDay|substr:'5':'9'}

{if $weekDay neq 0 and  $weekDay neq 6}
    <th>
        <div style="text-align: center; width:{$tableTdWidth * ($groupMaxCostData['groupMaxCostTimes'][$monthDay] + 1)}px">{$monthDay|substr:'5':'9'}<div>
    </th>
{else}
    <th style="background-color: gray;">
        <div style="width:{$tableTdWidth * ($groupMaxCostData['groupMaxCostTimes'][$monthDay] + 1)}px">{$monthDay|substr:'5':'9'}<div>
    </th>
{/if}

相等与不等

eq、neq
和shell的写法接近

$var eq 5

是否有值

{if $var}
2
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:726443次
    • 积分:17262
    • 等级:
    • 排名:第557名
    • 原创:210篇
    • 转载:9篇
    • 译文:2篇
    • 评论:22条
    博客专栏
    最新评论