One obvious downside of the previous method of loading a filter plug-in is that you need to use the load_filter
method on every template that you want the filter to execute. What if you want the filter to run on your entire website or application? This can be done by automatically loading filters with the autoload_filters
Smarty property.
We can do this by changing the value of this variable directly in the Smarty source code. Look for the Smarty.class.php
file and change the autoload_filters
variable, as shown next:
<?php
// inside Smarty.class.php ..
/**
* This indicates which filters are automatically loaded into Smarty.
*
* @var array array of filter names
*/
var $autoload_filters = array(‘output’ => array(‘append_benchmark_data’));
// ..
?>
The change above will tell Smarty to always load the given output filter plug-in. You will still need to create the plug-in file and name the function within it as explained in the...