clops
clops

Reputation: 5235

Eval Smarty Code inside a Smarty Template

is there a way to evaluate Smarty Code inside an existing Smarty template? For example, I may have the following construct:

smartyTemplate.tpl

<body>
  <div id="dynamicPart">
     {$valueFromDatabase}
  </div>
</body>

Whereas the Smarty variable $valueFromDatabase contains another Smarty Template which I would like to be inserted in place of the variable and then evaluated as a template (with all the logic expressions in replacements neccessary).

Upvotes: 1

Views: 1557

Answers (2)

karim
karim

Reputation: 11

{eval var=$valueFromDatabase}

will work

Upvotes: 1

pocketfullofcheese
pocketfullofcheese

Reputation: 8847

without a custom resource, you could have just used an {include file="your/template.tpl"}. Or render the template from the database in code using $smarty->fetch("your/template.tpl") and assigning that to $valueFromDatabase.

Upvotes: 1

Related Questions