Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

how $autoload_filters should work?

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
genie_ru
Smarty n00b


Joined: 15 Apr 2004
Posts: 4
Location: Russia

PostPosted: Thu Apr 15, 2004 1:23 pm    Post subject: how $autoload_filters should work? Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Apr 15, 2004 2:34 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
genie_ru
Smarty n00b


Joined: 15 Apr 2004
Posts: 4
Location: Russia

PostPosted: Thu Apr 15, 2004 2:52 pm    Post subject: Reply with quote

> just, make sure that autoload_filters is setup correctly everytime you use smarty

thank you Smile 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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP