[英]Smarty dynamic variable issue
Unfortunately, in my current workplace, I have to use Smarty on a project they had before i was employed. 不幸的是,在我目前的工作场所中,我必须在他们受雇前的一个项目中使用Smarty。
Anyway, I am trying to call in a Dynamic html title for each category in the app. 无论如何,我试图为应用程序中的每个类别调用动态html标题。
So for example, the title used to be pageTitle="{$category}
in {$areaname}
". 因此,例如,标题以前是
{$areaname}
pageTitle="{$category}
。
However I now want it to be: pageTitle="{html_title}"
. 但是我现在希望它是:
pageTitle="{html_title}"
。 Within html_title
(from db), is a string, for example: " Monkeys in the {areaname}
" Where {areaname}
could be "jungle
". 在
html_title
(来自db)中,是一个字符串,例如:“ Monkeys in the {areaname}
”其中{areaname}
可能是"jungle
”。
When I output the result, I get: 输出结果时,我得到:
"Monkeys in {areaname}"
. "Monkeys in {areaname}"
。
So to cut a long story short, its not recognizing the variable. 因此,简而言之,它无法识别变量。 It is treating it as a string.
它将其视为字符串。 I have googled my head off and can't find an answer.
我已经用谷歌搜索了,找不到答案。 I hate smarty!
我讨厌聪明!
Please help! 请帮忙!
Couldn't you just do something like 你不能做这样的事情吗
$html_title = preg_replace("/{areaname}/", "jungle", $html_title);
after fetching the title from the database? 从数据库中获取标题后?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.