Forums / Developer / Execute template code from with object attribute / Comment44109
James Robertson
Thursday 18 May 2006 3:24:55 pm
Solution supplied by eZ systems [thanks Kristion] for Exponential version 3.6.4. It can be added as a 'template operator' extension [good luck working out how to do that ;-]:
/* * WARNING: * - This function works directly towards the template system, * and might not be compatible with new versions of Exponential. * - The evaluated code will run in interpreted mode which can behave (sligtly) * different from compiled code, and is slower. * - By using fetches and templatecode in content object attributes you can * make a system which is very hard to maintain! * * This code should ONLY be used by professionals who understands what they are doing */ function ezeval( $templateText ) { include_once( 'kernel/common/template.php' ); include_once( 'lib/eztemplate/classes/eztemplate.php' ); $tpl =& templateInit(); $root = array( EZ_TEMPLATE_NODE_ROOT, false ); $resourceData = array( 'resource' => 'design', 'template-filename' => 'eval_code' ); $rootNamespace = ''; $output = ''; $tpl->parse( $templateText, $root, $rootNamespace, $resourceData ); $tpl->process( $root, $output, '', '' ); return $output; }