Now after some mistypes, I want to delete my bad custom settings.
Unfortunately as at inserting, we cannot use HostController because it provides only querying information, no update or insert, and however DataProvider has method for adding new setting but there is no method for delete.
Now we know what we can use so let's search something useful. After some thinking and searching in DotNetNuke api I realized that: there is nothing for delete host setting. At this point I decided, I return to the pure sql and there is a simple solution:
public static void InsertSetting(string key, string value)
{ var dp = DataProvider.Instance(); dp.AddHostSetting(key, value, false, -2); // -2 is not an existing user. -1 is system default DotNetNuke.Common.Utilities.DataCache.ClearHostCache(true);
}
There is a new DotNetNuke api method there:
ClearHostCache(bool Cascade)The explanation is simple: HostController.Instance is a cache object and after deleting from database, we have to refresh the host cache.
And of course after the work, we can open a cold beer...
No comments:
Post a Comment