Page 1 of 1

Smarty not processing when in text field

Posted: Thu May 18, 2017 8:10 pm
by magallo
I have a custom module that stores items.
I'm editing a Description field with cms_textarea enablewysiwyg=true
and adding {get_template_vars} in the body (for example).
When the field is pulled it shows the literal {get_template_vars} text without processing smarty.
Is there something i'm missing?
thanks

Re: Smarty not processing when in text field

Posted: Thu May 18, 2017 8:19 pm
by calguy1000
A textarea is just a text area. that's it.

If you want to treat it like a template in your module, then you need to pass it through smarty.

Code: Select all

$tpl = $smarty->CreateTemplate('string:'.$the_text_area_content);
// assign some smarty variables here.
// i.e:  $tpl->assign('foo',$foo);
$output = $tpl->fetch();
// or optionally $tpl->display();
BTW. It is not advisable for security purposes to do this for content that is edited on a public facing page.

Re: Smarty not processing when in text field

Posted: Thu May 18, 2017 8:52 pm
by magallo
Thanks calguy1000,
i was reasoning correctly, was missing the execution.
The editing is happening in the admin area so i assume security is not compromised.