【问题标题】:How to print current year in 'vm' template (UltraCart)如何在“vm”模板中打印当前年份(UltraCart)
【发布时间】:2018-02-06 04:56:33
【问题描述】:

我正在使用 UltraCart 主题并希望在页脚部分打印当前年份,如下所示:

<div class="copyright_center">&copy; Copyright MyWebSite</div>

我正在更改 footer.vm 模板文件,但我不知道 'vm' 模板语法。

我已经试过了:-

#set ($date = $dateUtil) 
#set ($current_time = $date.getCurrentDate())
#set ($theYear = $date.getCurrentDate("yyyy", $locale))

<div class="copyright_center">&copy; Copyright $theYear MyWebSite</div>

但这对我不起作用。任何人都有想法,如何解决它?

【问题讨论】:

    标签: templates virtual-machine velocity ultracart


    【解决方案1】:

    在速度工具 jar 中你有 DateTool 对象

    在 Velocity 模板中使用日期和日历的工具

    如果给date对象提供年份格式,你需要做的就是:

     $date.get('yyyy')
    

    【讨论】:

    • 我正在开发 UltraCart,但它不适合我,当我在我的速度模板文件上使用它时,它会在浏览器上打印同样的东西。
    猜你喜欢
    • 2017-05-05
    • 2011-09-09
    • 2017-10-22
    • 1970-01-01
    • 1970-01-01
    • 2020-09-07
    • 1970-01-01
    • 2011-06-01
    相关资源
    最近更新 更多