|
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 |
edduvs Smarty Rookie
Joined: 27 Jun 2011 Posts: 10
|
Posted: Mon Jun 27, 2011 7:43 pm Post subject: Addon request !? |
|
|
Can someone here make an addon or plugin so on the $smarty->display() action, the final result can be filtered by a bad words filter ? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Jun 27, 2011 8:11 pm Post subject: |
|
|
Here is a simple start:
Code: | <?php
// put this in your application
function bad_words($tpl_output, $smarty)
{
$words = array('fooey','blargh'); // bad words
$tpl_output = str_replace($words,'', $tpl_output);
return $tpl_output;
}
// register the outputfilter
$smarty->registerFilter('output','bad_words');
$smarty->display('index.tpl');
?> |
|
|
Back to top |
|
edduvs Smarty Rookie
Joined: 27 Jun 2011 Posts: 10
|
Posted: Mon Jun 27, 2011 11:02 pm Post subject: |
|
|
Ok mohrt, i see that quite logic, but, can't I have it embedded in the smarty compile proccess so I wouldn't add it in every file ? What do I need to modify if so ? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Jun 27, 2011 11:22 pm Post subject: |
|
|
you only need to put it in your code once, just before display() call. you can include it from another file if you want. you can also use a plugin from the plugins dir, see the documentation how to set one up. |
|
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
|