Dienstag, 19. Februar 2013

Debugging SharePoint

 

To know which w3wp Process you need to attach just use this command:

C:\wondows\System32\inetsrv\appcmd list wp

Found here: Attaching specific W3WP Worker Process in SharePoint Custom Code Debugging.

Mittwoch, 13. Februar 2013

Change from Managed to Structural Navigation in SharePoint 2013 publishing programmatically


I developped a WebTemplate based on a Publishing site definition. The publishing features activated Managed Navigation by default. And I was unable to find how to change it programmatically. Then I used SharePoint Manager 2013 and found in the web Properties following key: SPFeatureProperty
And this was the Value:
<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<WebNavigationSettings Version="1.1">
  <SiteMapProviderSettings>
    <SwitchableSiteMapProviderSettings Name="CurrentNavigationSwitchableProvider" UseParentSiteMap="True" />
    <TaxonomySiteMapProviderSettings Name="CurrentNavigationTaxonomyProvider" UseParentSiteMap="True" />
    <SwitchableSiteMapProviderSettings Name="GlobalNavigationSwitchableProvider" UseParentSiteMap="True" />
    <TaxonomySiteMapProviderSettings Name="GlobalNavigationTaxonomyProvider" UseParentSiteMap="True" />
  </SiteMapProviderSettings>
<NewPageSettings AddNewPagesToNavigation="True" CreateFriendlyUrlsForNewPages="True"/>
</WebNavigationSettings>

I Compared it tot he value of a second web I configured through the SiteSetting interface:
<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<WebNavigationSettings Version="1.1">
  <SiteMapProviderSettings>
    <SwitchableSiteMapProviderSettings Name="CurrentNavigationSwitchableProvider" TargetProviderName="CurrentNavigation" />
    <TaxonomySiteMapProviderSettings Name="CurrentNavigationTaxonomyProvider" Disabled="True" />
    <SwitchableSiteMapProviderSettings Name="GlobalNavigationSwitchableProvider" UseParentSiteMap="True" />
    <TaxonomySiteMapProviderSettings Name="GlobalNavigationTaxonomyProvider" UseParentSiteMap="True" />
  </SiteMapProviderSettings>
  <NewPageSettings AddNewPagesToNavigation="True" CreateFriendlyUrlsForNewPages="True"/>
</WebNavigationSettings>

So I started looking for the WebNavigationSettings Class and I found this Post: Working with publishing navigation in SharePoint 2013
Here ist the code like it should be in a feature receiver:
SPWeb web = (SPWeb)properties.Feature.Parent;
myNavigationSettings.CurrentNavigation.Source = StandardNavigationSource.PortalProvider;
myNavigationSettings.Update();

StandardNavigationSource is an enumeration and looks like this:
public enum StandardNavigationSource
    {
        Unknown = 0,
        PortalProvider = 1,
        TaxonomyProvider = 2,
        InheritFromParentWeb = 3,
    }

Montag, 4. Februar 2013

Site Provisioning Best Practice

 

Site Provisioning is always important in SharePoint Projects. In this article I’ll put every interesting information on this subject.

Even if its about SharePoint 2010, following Post is really interesting and in my eyes a must read: SharePoint 2010 and web templates.

So what are the different Provisioning Possibilities:

1 Full-blown Site Definition:

In my opinion site Definitions are not really an option because it’s not supported to change the onet.xml once a single Site is provisioned using this site definition. A possible Workaround is the “minimal Site Definition approach”.

2 minimal Site Definition

I’ll update this part once I explore this possibility.

3 WebTemplates

I tried Vesa Juvonen’s solution in the above linked Post. It worked fine even with SharePoint 2013. I just needed make some small changes.

So What Changed in SharePoint 2013?

In 2013 It seems to me that deploying a Web with a WebTemplate will fail if some features from the <SiteFeatures> section of the web Onet.xml are not activated.

So this part was not working:

image

I simply included this part in the WebFeature part:

image