Set the default filters

83 views
Skip to first unread message

kleer94

unread,
Aug 15, 2011, 7:28:18 PM8/15/11
to PHP Savant
While I was working with Savant I noticed that I can not set more than
one default filter.
I was trying to do this using "__construct" method,
which the argument's key "filters" was an array of "addFilters"
arguments.
When I added my filter using addFilters method, it was running
correctly.
In example this three lines were running without any errors:
$tpl=new Savant3();
$tpl->addFilters(array('Savant3_Filter_trimwhitespace','filter'));
$tpl->addFilters(array('Savant3_Filter_myfilter','filter'));

but not these ones:
$config=array();
$config['filters']=array(array('Savant3_Filter_trimwhitespace','filter'),array('Savant3_Filter_censorship','filter'));
$tpl=new Savant3($config);

I was little suprised when i seen error after this part of code.
Now I know that I can set only one default filter, but it was
important for me to load them more.
I replaced this 160th line of Savant3.php file:
$this->addFilters($config['filters']);

on those two lines:
foreach($config['filters'] as $filter)
$this->addFilters($filter);

Now I can set more than one default filter.
I wrote about it, because I'm hope that I will not have to change this
manually ;)
Thanks for reading and sorry for maybe few spelling mistakes, Krzysiek.
Reply all
Reply to author
Forward
0 new messages