by Keyvan Nayyeri via Keyvan Nayyeri on 1/11/2007 6:09:22 PM
In addition to site configurations, Community Server provides several settings for each site. Most of these settings have default values and you can set them in Control Panel and web UI.
CommunityServer.Components.SiteSettings is a code representation of all site settings for a specific Community Server instance.
As you know, several Community Server instances can be installed in same database. Here a property which is named SettingsID comes handy and helps to distinguish each instance (there is also an ApplicationName property to identify site settings). A SiteSettings object has a one to one relationship with a SettingsID.
By understanding this important key you can start coding against site settings by using static methods in CommunityServer.Components.SiteSettingsManager namespace and CommunityServer.Components.SiteSettings lass. SiteSettings has tons of properties and their name suggests their application so I don't step into their details. Based on your needs you can get or set these settings in your code.
But SiteSettingsManager namespace helps you to get an instance of SiteSettings object or save one. Here is a brief description about its common methods:
Alright, seeing some examples completes this discussion.
Here UpdateCompanyName() method updates the company name for current application then saves it. In this code first I created a SiteSettings object and set it to current application settings using SiteSettingsManager.GetActiveSiteSettings() then changed company name and used SiteSettingsManager.Save() method to store my change.
void UpdateCompanyName()
{
SiteSettings settings = new SiteSettings();
settings = SiteSettingsManager.GetActiveSiteSettings();
settings.CompanyName = "Telligent Systems";
SiteSettingsManager.Save(settings);
}
In second example UpdateAllCopyrights() method updates copyright notices for all applications. It gets an ArrayList of all SiteSettings using SiteSettingsManager.AllSiteSettings() then iterates through them and updates all copyright notices. On each iteration it stores changes by calling SiteSettingsManager.Save().
void UpdateAllCopyrights()
ArrayList settingsList = SiteSettingsManager.AllSiteSettings();
foreach (SiteSettings settings in settingsList)
settings.Copyright = string.Format
("Copyright © {0} - Licensed under" +
"Creative Commons Attribution 2.5 License.", DateTime.Now.Year.ToString());
Now playing: Man On The Line - Chris De Burgh
Original Post: CS Dev Guide: SiteSettings
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.