0

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!

6
  • Monkeys in the {$areaname} will not work? Commented Nov 21, 2012 at 10:23
  • I can't work out why? In Smarty can you not have a variable within a variable? Commented Nov 21, 2012 at 10:25
  • How do you set "{html_title}" ? In this (wrong) way ? $smarty->assign("html_title","Monkeys in {areaname}") ? Commented Nov 21, 2012 at 10:34
  • It is set using a plugin: {getServiceCategoryTitle categoryID=$id assign="html_title"} Commented Nov 21, 2012 at 10:44
  • And the value from the database is "Monkey in the {$areaName}". {$areaName} is already assigned elsewhere on the page. But instead of displaying the value of {$areaName} it is actually displaying {$areaName} Commented Nov 21, 2012 at 10:46

1 Answer 1

1

Couldn't you just do something like

$html_title = preg_replace("/{areaname}/", "jungle", $html_title);

after fetching the title from the database?

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I didn't want to go down this road but oh well. I hate Smarty!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.