Creating custom Filters in Active Forums is a great way to add more functionality to your forums. Currently there are three types of filters, Regex, text replacement and emoticon. I will give a short explanation of each type along with an example of a useful filter. You can find all the filters under the “Filters” tab in the control panel.
For all of my examples you will need to click the "Add Filter Item" link, and add my bolded text into the pop-up box.
Also, note that you will need to have filters enabled for your forums. You can turn them on in the features section.
The first type of filter is a simple text replacement. This could be useful if you want to have a family friendly environment without curse words. I created a filter that will search for your favorite “swear word” and replace the letters with asterisks.
Filter:
Text to find: BadWord
Replacement: *******
Filter Type: MarkUp/Text
You will have to create a separate filter for every word you want to block.
Input:
Result:
Using filters you can add custom emoticons to your forums. First, you will need to find the Emoticons folder. It is located in the DesktopModules/ActiveForums/themes/ directory, in the subfolder that matches your current theme. All the default emoticons are 20x20 pixels. For the sake of layout, I will make mine the same size.
Here is the emoticon I edited in Photoshop, you can obviously use whatever images you want.
Save the image into the Emoticons directory. I know .png and .gif files both work and are small in size, so I recommended either file type.
Filter:
Text to find: Peace!
Replacement: /emoticons/peace.gif
Filter Type: Emoticon
Once you have the filter saved, you can either type the text (Peace!) or click the emoticon in the topic editor window.
As you can see, when you click the image, it automatically types in the “Text to find.” (I clicked it multiple times.)
When I submit the post, the text is replaced with my little emoticon.
The third and last filter type is a bit more complicated. Here is a short description of Regex (from Wikipedia.org)
"In computing, regular expressions provide a concise and flexible means for identifying strings of text of interest, such as particular characters, words, or patterns of characters. Regular expressions (abbreviated as regex or regexp, with plural forms regexes, regexps, or regexen) are written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification."
The forums only have one Regex filter by default, the filter that converts [img]http://www.domain.com/image.jpg[/img] into the proper HTML syntax to display an image. The benefit of using filters in this case is that you can allow your users to post images while still having HTML input disabled. Having HTML enabled is a security concern for a lot of sites, so this provides a safe way to extend functionality.
Another very useful Regex filter you can add is: [url]www.domain.com[/url]. This is very similar to the [img] filter in that it allows users to add HTML content with HTML input disabled. This particular filter will turn whatever is in between the [url] [/url] tags into a clickable link.
Filter:
Text to replace: (\[url](.*?)\[\/url\])
Replacement: <a href="http://{2}">{2}</a>
Filter Type: Regular Expression
Input:
Result:
(You may not be able to tell, but that is a hyperlink.)
I hope this can get you started. If you have any other useful filters that you use on your forums, please share them!
Ben