Tuesday, August 25, 2009

Enable publishing feature programmatically in MOSS 2007 site

In SharePoint, integrating publishing feature is possible only in MOSS 2007 site and not in WSS site.By turning on publishing feature you can use Web Content Management(WCM) feature in the site.Once the WCM feature is enabled you can then brand the site with your custom look and feel and can also enable the multilingual support in the site. The multilingual feature helps in creating different folder-based sites according to the languages set to the site.

While creating a site collection or site & workspaces using SharePoint API , you can add these two lines code to enable the publishing feature.Provided below is an example using C# for enabling publishing feature at site collection level.

Code in C#

// Turn on publishing feature
// objSiteCollection is the Site Collection object
objSiteCollection.Features.Add(SPFarm.Local.FeatureDefinitions["PublishingSite"].Id);

// Make the necessary changes to the local server to use the feature
SPFarm.Local.FeatureDefinitions["PublishingSite"].Provision();


I have written the same here also:Enable publishing feature programmatically in MOSS 2007 site


Samarendra Swain

No comments:

Post a Comment