Community   »   Forums
RSS Feed Available AddThis - Bookmarking and Sharing Button Printer Friendly

PrevPrev NextNext

Active Forums Filters - Explained with Examples

by Ben on 31 Dec 2008 11:41 AM

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

6 Comments for Active Forums Filters - Explained with Examples

Frozen DNN
Frozen DNNUser is Offline
31 Dec 2008 03:21 PM

Thank you Ben. Very useful topic. Can you please tell me whether I can ban an IP address from posting in the forums (not from visiting the website) with the help of regex?
marbab
marbabUser is Offline
01 Jan 2009 02:00 AM

Thanks.very useful.
Ben
BenUser is Offline
02 Jan 2009 12:39 AM

Frozen... Here is what you are looking for:

http://www.mitchelsellers.com/blogs...ilter.aspx
Harrier
Harrier
11 Jan 2009 08:16 PM

Thanks Ben. The url pattern was exactly what I was looking for.
Eoghan  ONeill
Eoghan O'NeillUser is Offline
19 Mar 2009 11:22 AM
www.cluas.com
Here's a simple enhancement for the filter that turns whatever is in between the [url] [/url] tags into a clickable link. With this enhancement the link generated will have the rel="nofollow" attribute assigned to it, this signalling to search engines that the link is not to be given any value when analyzing a page / links on it. This is a standard best practice on forums to deal with spammers:

The filter to do this is:

Text to replace: (\[url](.*?)\[\/url\])
Replacement: <a rel="nofollow" href="http://{2}">{2}</a>
Filter Type: Regular Expression
jbrunken
jbrunkenUser is Offline
20 Jan 2010 09:35 AM

I ran into a bit of a problem with this when I was trying to add a filter last night. It looks like "^" and "$" both cause problems. If you enter an expression with either of those values, they mess up the control panel display and you have to reset all of your filters (or delete the offending filter with SQL).

I also noticed that the escapes "\" aren't showing up in the expressions until you click edit.

-JB
Quick Reply
toggle
  Username:
Subject:
Body:
Security Code:
CAPTCHA image
Enter the code shown above in the box below
Subscribe: Check the box to receive email notifications for this topic.

Submit
Active Forums 4.2