Question: Injecting template code within a currently processed template
| From: | Andr� Rabold | Date: | Wed, 13 Nov 2002 14:01:44 +0000 |
| Subject: | Question: Injecting template code within a currently processed template | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-6416@lists.php.net to get a copy of this message | ||
I want to create a plugin function which is able to dynamically include
other templates. Such a function must be executed before the script
is compiled and injects template code into the currently processed
template.
The only plugin type which could be able to solve my problem is the
"compiler" plugin but it doesn't fit my needs. I could only do some
regex replacements or something similar which isn't what i want.
For now I solved the problem writing a normal function plugin:
<?php
function smarty_function_injectTemplate ($params, $smarty) {
// ... do some stuff here
$myTemplate = $params["template"];
$smarty = new Smarty();
$smarty->assign( $myVars );
$smarty->display( $myTemplate );
}
?>
This isn't nice :-( Does anybody has a better solution?
Thanks in advance,
André