Re: HTML_Template_Xipe
| From: | Wolfram Kriesing | Date: | Sat, 28 Jun 2003 23:36:46 +0000 |
| Subject: | Re: HTML_Template_Xipe | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-6303@lists.php.net to get a copy of this message | ||
Tommy Ipsen wrote:
Hi I have a problem nesting templates when using HTML_Template_Xipe... This is the short version of what I have: index.php: $options = array(i understand your problem. and in the way of using a variable there like this: {%include $contentfile%} it is not possible with Xipe (yet) but i would suggest that you do another thing, may be its just a work around, but it worked fine (at least for me) use a standard php-include like this: {include $contentfile} this will be parsed by the template engine and replaced by <?php include $contentfile ?> which means that $contentfile is a valid file name of a php-file (not a template!). So that you have a little bit of extra work which is compiling the template in the $contentfile. i.e. if $contentfile is 'htdocs/contentFile.php' then you simply compile the template inside of this file and you have the same effect. hth -- Wolfram http://opensource.visionp.de ... authentication system .... http://sf.net/projects/auth'templateDir' => 'templates', // root-directory for storing templates 'compileDir' => 'tmp', // directory for compiled templates //'debug' => 1, // debug level //'filterLevel' => 9, // :TODO: filters nothing - only during debug-face! 'forceCompile' => true, // :TODO: forces a recompilation of templates - only during debug-face! //'logLevel' => 0, // :TODO: logs everything - only during debug-face! //'enable-Cache' => true, // enable caching of templates - remember administrative possibility to recompile! //'locale' => '', // no translation of templates - therefore locale is not required! //'verbose' => true, // :TODO: should be false on a production system! 'autoBraces' => false); // stuff... $tpl = new HTML_Template_Xipe($options); $tpl->compile('index.tpl'); include($tpl->getCompiledTemplate()); index.tpl: <html><body> // stuff... {%include content.tpl%} </body></html> This works fine, meaning content.tpl is also parsed as a template by Xipe. But I would really like to do something like:{%include $contentfile%}Where $contentfile contains a filename depending on a parameter given by the user. The above code however is only possible like this:{include 'templates/filename.tpl';}Which results in the template not being parsed by xipe and the $variables in filename.tpl appearing "as written" ie. not substituted with the value of the variable! Therefore my question is how to include (and parse) a file/template when the name of the file/template is stored in a variable!