Convert provided string as Smarty template

149 views Asked by At

I am new to smarty template

There is one crazy requirement where I need to convert provided smarty code as a string into smarty template.

Let me explain

1) In page post from user I will get the smarty template which they have typed in textarea eg.

{if '%%loyaltyPoints%%' >=1000}  
 Thanks for being a Gold member!  
{elseif '%%loyaltyPoints%%' < 1000 and '%%loyaltyPoints%%' > 500}  
 Thanks for being a Silver member!  
{else}  
 Thanks for being a Bronze member!  
{/if}  

2) This will be get in php post -- I want to pass this code to template and execute there

3) ie. This dynamic code should generate in template and the passed value '%%cf_loyaltyPoints%%' need to be compared in if else conditions and specific output is printed.

I have tried using $smarty->fetch('string:'.$template_string); with no success.

Please suggest any better way

0

There are 0 answers