|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
genie_ru Smarty n00b
Joined: 15 Apr 2004 Posts: 4 Location: Russia
|
Posted: Thu Apr 15, 2004 1:23 pm Post subject: how $autoload_filters should work? |
|
|
First of all I created prefilter 'prefilter.add_template_name.php' and placed it to 'plugins' directory.
Code: | <?php
// put this in your application
function smarty_prefilter_add_template_name($tpl_source, &$smarty)
{
return "<!-- ========== start {\$smarty.template} ========== -->\n".$tpl_source."\n<!-- ========== end {\$smarty.template} ========== -->";
}
?> |
Than I try to make it 'autoloaded' for every template on my project.
Code: | $smarty->autoload_filters = array('pre' => array('add_template_name'),
'output' => array());
|
I expected that all templates will be filtered by my prefilter. But as I understood, this prefilter is used only for templates which my script calls.
Code: | $smarty->autoload_filters = array('pre' => array('add_template_name'),
'output' => array());
$smarty->display("all_templates.tpl");
|
Now my prefilter turns on 'all_templates.tpl' and all templates inside it ({include}). My solution is to place in 'all_templates.tpl' all templates used in project. The question is: is it possible to use one script to define prefilter for all possible templates that Smarty compile? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Apr 15, 2004 2:34 pm Post subject: |
|
|
why do you want this?
just, make sure that autoload_filters is setup correctly everytime you use smarty. put your smarty-configuration in one central config.php that is used by each page that uses $smarty. then the filters are applied as soon as a template is used.
why would one one to have the filters applied before? |
|
Back to top |
|
genie_ru Smarty n00b
Joined: 15 Apr 2004 Posts: 4 Location: Russia
|
Posted: Thu Apr 15, 2004 2:52 pm Post subject: |
|
|
> just, make sure that autoload_filters is setup correctly everytime you use smarty
thank you i'm newbee to Smarty and php.
> why would one one to have the filters applied before?
to use $smarty.template, if I understood your question right |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|