聪明的分配变量
我试图通过这样做在我的 .tpl 中分配一个变量,
{assign var="image" value="images/stores/{$location.storename|regex_replace:"/[' ']/":"-"|lower}.jpg"}
但是我收到了这个错误,
Smarty 错误:[stores/view-store.tpl 第 135 行]:语法错误:无效属性名称:'|lower'
如何停止此错误,但仍将返回信息的大小写改为小写?
I am trying to assing a variable in my .tpl by doing this,
{assign var="image" value="images/stores/{$location.storename|regex_replace:"/[' ']/":"-"|lower}.jpg"}
however I am getting this error,
Smarty error: [in stores/view-store.tpl line 135]: syntax error: invalid attribute name: '|lower'
How Can i stop this error but still drop the casing of the returned info to lowercase?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
即使你降价了,你仍然会遇到问题。 {} 块内不能包含 {} 块。也不能将“”嵌套在“”中。
http://www.smarty.net/docsv2 /en/language.custom.functions.tpl#language.function.assign
查看该页面,查看复杂的示例。您将使用类似的内容
这可能对您也有用:
http:// /www.smarty.net/docs/en/language.function.eval.tpl
但最终,您应该在 PHP 端执行此操作,逻辑和代码并不意味着位于模板中,除非确实存在没有其他选择。
Even if you take lower off you're still going to have problems. You can't have a {} block inside a {} block. Nor can you have "" nested in "".
http://www.smarty.net/docsv2/en/language.custom.functions.tpl#language.function.assign
Look at that page, check out the complex example. You'll use something like
This might also be useful for you:
http://www.smarty.net/docs/en/language.function.eval.tpl
Ultimately though, you should be doing that on the PHP side, logic and code is not meant to be in the template unless there really is no other choice.