Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Addon request !?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
edduvs
Smarty Rookie


Joined: 27 Jun 2011
Posts: 10

PostPosted: Mon Jun 27, 2011 7:43 pm    Post subject: Addon request !? Reply with quote

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


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Jun 27, 2011 8:11 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
edduvs
Smarty Rookie


Joined: 27 Jun 2011
Posts: 10

PostPosted: Mon Jun 27, 2011 11:02 pm    Post subject: Reply with quote

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


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Jun 27, 2011 11:22 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons 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