【问题标题】:Smarty {fetch} in .tpl and Variables.tpl 和变量中的 Smarty {fetch}
【发布时间】:2015-11-26 17:13:24
【问题描述】:

我在 .tpl 文件中使用 smarty,我有

{fetch file='http://domain.com/directory/{$wtc_location}/{$wtc_year}/{$wtc_stormname}.php'}

但它没有拉变量。我试过{$smarty.get.wtc_location} 仍然没有。加载变量的解决方案是什么?

提前致谢。

【问题讨论】:

  • 你为什么说“它不拉变量”?如果即 $wtc_location 为空,则必须在模板或 php 文件中使用 $smarty->assign('wtc_location', 'some location'); 为其分配一些值
  • 所有变量都设置好了,它只返回 [link]domain.com/directory{$wtc_location}/{$wtc_year}/{$wtc_stormname}.php[/link] 但我可以把那行放在外面的 fetch 并正确提取所有变量。

标签: smarty


【解决方案1】:

我看到了问题。你不能在 smarty 函数中调用 smarty 变量,就像它是一个模板一样,你必须使用修饰符 cat 来组合它:

{fetch file='http://domain.com/directory/'|cat:$wtc_location|cat:'/'|cat:$wtc_year|cat:'/'|cat:$wtc_stormname|cat:'.php'}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-12
    • 2012-11-28
    • 1970-01-01
    • 2022-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多