Evaluate Smarty output from a UDT (User Defined Tag)

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
savagekabbage
Forum Members
Forum Members
Posts: 75
Joined: Mon Apr 23, 2007 3:51 pm
Location: Northern Virginia, United States

Evaluate Smarty output from a UDT (User Defined Tag)

Post by savagekabbage »

I had the need to have smarty output evaluated from a User Defined Tag recently, and couldn't find anything searching the forums. 

This is how I ended up doing it, there may be a better way.

Code: Select all

global $gCms;
$smarty =& $gCms->GetSmarty();

$output = "Whatever...";
$output .= "{* Smarty tags will work. *}";

require_once $smarty->_get_plugin_filepath('function', 'eval');
echo smarty_function_eval(array('var' => $output), $smarty);
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Evaluate Smarty output from a UDT (User Defined Tag)

Post by calguy1000 »

Code: Select all

{capture assign='tmp'}{my_udt_name}{/capture}{eval var=$tmp}
see:  smarty.php.net/manual  (I think it's required reading for CMS users).
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.
Post Reply

Return to “Tips and Tricks”