SharePoint Tip of the Day – Can’t find your custom site definition in SharePoint 2013 when creating your root variation label ?


As in previous SharePoint versions, whenever you create your root variation label, you’ll need to specify the template associated with all the labels.

Unfortunately the UI seems to only propose the Publishing Site (CMSPublishing#0) and the Publishing Site With Workflows (BlankInternet#2). While these two will fit most needs, I still find handy to have my own customized site definition, deriving from the OOTB ones that will only include the feature that I need and automatically do specific action upon provisioning.

01

So how can you add your own site definition to the list like in the image above ?Time to do a little bit of reflection to see how this administration page is working and let’s call ILSpy to the rescue !

The page is inheriting from Microsoft.SharePoint.Publishing.Internal.CodeBehind.VariationLabelPage

and will load available choices through its private method private SortedDictionary<string, string> PublishingTemplates which is getting the available templates from the site collection through GetCustomWebTemplates and filtering the results through VariationLabelPage.FindFilterCategory to only retain the ones which have a property FilterCategories with the value “PublishingSiteTemplate”…

02
03

Knowing that, it’s only a matter of adding that property to your webtemp entry and voilà, it’s now usable (do an IISReset to ensure the choices, loaded from SharePoint internal cache, are reloaded).

04

Hope it will help !

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s