The following example shows you how to modify web site properties in your code:
[C#]
using CMS.CMSHelper; using CMS.SiteProvider; using CMS.WorkflowEngine;
...
// Get current site name (you can use code name of the required site instead) string siteName = CMSContext.CurrentSiteName;
// Check if the site name is available if (siteName != null) { try { // Stop the site because we will change the domain of the site SiteInfoProvider.StopSite(siteName);
// Get site info SiteInfo si = SiteInfoProvider.GetSiteInfo(siteName);
if (si != null) { si.DisplayName = "New dsiplay name"; si.Description = "New description";
// Change domain of the site si.DomainName = "mynewdomain.com";
// Set new domain alias with default content language set to en-US SiteInfoProvider.AddDomainAlias(siteName, "newdomainalias", "en-US");
// Save the changes SiteInfoProvider.SetSiteInfo(si); }
// Run the site SiteInfoProvider.RunSite(siteName);
lblInfo.Text = string.Format("Site '{0}' has been edited.", siteName); } catch (RunningSiteException ex) { lblError.Text = "Site cannot be started.<br />Original exception: " + ex.Message; } catch (Exception ex) { lblError.Text = "Error when modifying site properties.<br />Original exception: " + ex.Message; } } |
Page url: http://devnet.kentico.com/docs/devguide/index.html?update_web_site_properties.htm