【问题标题】:How to get smarty value in tpl file - cs cart?如何在 tpl 文件 - cs cart 中获得 smarty 值?
【发布时间】:2015-07-09 08:31:40
【问题描述】:

我正在尝试在我的 profile_account.tpl 文件中获取 smarty 值。

{capture name="profile_pic"}{$user_data.main_pair.icon.image_path}{/capture}

如何在top_quick_links.tpl 中获得此信息?

"$smarty.capture.profile_pic"

但这不会返回任何值。我该怎么做?

【问题讨论】:

    标签: php cs-cart


    【解决方案1】:

    也许您没有为模板引擎分配$user_data 数组。 您的解决方案不是那么优雅。我建议你把它放到你的控制器文件中:

    这是在 CS-Cart 中为 Smarty 分配自定义变量的方式

    Registry::get("view")->assign("user_profile_picture", $user_data['main_pair']['icon']['image_path']);
    

    并且直接在.tpl文件中使用这个变量:

    <img src="{$user_profile_picture}" />
    

    【讨论】:

      【解决方案2】:

      4.x 版本请使用以下代码:

      {$smarty.capture.profile_pic nofilter}
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多