简体   繁体   中英

Smarty dynamic variable issue

Unfortunately, in my current workplace, I have to use Smarty on a project they had before i was employed.

Anyway, I am trying to call in a Dynamic html title for each category in the app.

So for example, the title used to be pageTitle="{$category} in {$areaname} ".

However I now want it to be: pageTitle="{html_title}" . Within html_title (from db), is a string, for example: " Monkeys in the {areaname} " Where {areaname} could be "jungle ".

When I output the result, I get:

"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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM