Smarty not processing when in text field

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Locked
User avatar
magallo
Forum Members
Forum Members
Posts: 105
Joined: Thu Mar 24, 2011 12:37 am

Smarty not processing when in text field

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Smarty not processing when in text field

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
magallo
Forum Members
Forum Members
Posts: 105
Joined: Thu Mar 24, 2011 12:37 am

Re: Smarty not processing when in text field

Post 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.
Locked

Return to “Developers Discussion”