In this article we will be seeing how to publish a content type in SharePoint 2010. In this article we will be seeing the following:
Steps Involved:
Publish a content type using console application: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint; using Microsoft.SharePoint.Taxonomy.ContentTypeSync;
namespace EMM { class Program { static void Main(string[] args) { using (SPSite site = new SPSite("http://servername:10/")) { using (SPWeb web = site.RootWeb) { SPContentType contentType = web.ContentTypes["_bContentType"]; if (ContentTypePublisher.IsContentTypeSharingEnabled(site)) { ContentTypePublisher ctPublisher = new ContentTypePublisher(site); ctPublisher.Publish(contentType); Console.WriteLine(contentType.Name + " is published successfully"); Console.ReadLine(); } } } } } } Go to Site Actions=> Site Settings => Galleries => Site Content Types => Manage publishing for the content type. You could see the content type is published successfully. Publish a content type using powershell script: $hubSite=Get-SPSite "http://servername:10/" $hubWeb=$hubSite.RootWeb $contentType=$hubWeb.ContentTypes["_bContentType"] $ctPublisher=New-Object Microsoft.SharePoint.Taxonomy.ContentTypeSync.ContentTypePublisher($hubSite) $ctPublisher.Publish($contentType)
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: