The following code example demonstrates how to get a DataSet with all global bad words stored in the system database. Using the WHERE condition, you can specify which particular bad words you want to retrieve.
[C#]
using System.Data; using CMS.SiteProvider;
...
// Set the WHERE condition string where = "WordIsGlobal = 1"; // Set the ORDER BY clause string orderBy = "WordExpression";
// Get a DataSet of Bad word info objects according to the given parameters DataSet ds = BadWordInfoProvider.GetBadWords(where, orderBy);
// Get a DataSet of Bad word info objects for given culture by its ID DataSet ds2 = BadWordInfoProvider.GetBadWords(1); |
In the code example below, you can see how a single bad word can be retrieved from the system database, updated with some changes and saved back to the database.
[C#]
using CMS.SiteProvider; using CMS.CMSHelper;
...
// First get the bad word info by its ID BadWordInfo bwi = BadWordInfoProvider.GetBadWordInfo(1);
// Set the WordReplacement property to the default value from the current site settings bwi.WordReplacement = BadWordInfoProvider.GetReplacementFromSettings(CMSContext.CurrentSiteName);
// Save object BadWordInfoProvider.SetBadWordInfo(bwi); |
Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?api_getting_and_updating_bad_words.htm