Page 1 of 1

Evaluate Smarty output from a UDT (User Defined Tag)

Posted: Tue Oct 02, 2007 3:42 pm
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);

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

Posted: Wed Dec 12, 2007 9:19 pm
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).