When many people are publishing content on a website, it leads to variety of opinions which is always good. But working with a large content team also brings complexity, like inconsistencies in the general understanding of what is appropriate for your audience and what is a harsh tone. With that in mind, we should avoid publishing offensive content at any cost. Keep in mind that sometimes the standard autocorrect creates more problems than it solves. With Sitefinity 10.1 you have the option to sanitize your content easily and remove any obscene words, such as those we can only refer to here by their first letter – let’s call them collectively the “X-word“.
With Sitefinity 10.1 you can create your own DataSanitizeProcessor and check all the content that is going into your Database. You need to inherit the ProcessorBase class and implement the IDataProcessor interface. The data processor is activated for each content type and its fields. If you want to apply a check to a field, return true in the ShouldProcess method. Here is a sample illustrating the idea:
When it comes to comments, the approach is different since the input comes from the directly from the frontend of the website. To deal with inappropriate comments and censor them you only need to override one method in comments.js. The JS file tells the client-side how to visualize the comments. To get the current implementation of the file, open Telerik.Sitefinity.Frontend.Comments.dll with JustDecompile and look in the resources folder for Telerik.Sitefinity.Frontend.Comments.MVC.Scripts.comments-list.js.
Copy the content into a new comments-list.js file and put it in the MVC folder under the Bootstrap resource package.
The last step is to change the implementation of the attachCommentMessage function. E.g.:
To avoid discrepancies after upgrading, the best practice is to get the latest version of the JS file and merge it with your version.
Even if you apply a basic replacement mechanism to handle the obscene words, the experience on your website will greatly benefit from it. If you don’t want to use this word sanitizer, you can always consider putting a jar in your office and collecting $1 for each bad word instead :).
Peter Filipov (Pepi) is a Product Builder focused on building the future of Sitefinity, relying on the newest technologies such as .NET 6 (and up), React and Angular. His previous experience as a Developer Advocate and Manager of Engineering helps him to understand the customers’ and market needs of Sitefinity. He also is passionate about being active and healthy.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.Learn More
Subscribe to get all the news, info and tutorials you need to build better business apps and sites
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.