vrijdag 22 juni 2012

SharePoint 2010: Manage navigation programmatically C#

How to set navigation options programmatically?

  • Don't inherit global navigation
  • Don't include pages in global navigation
  • Include subsites in quicklaunch
  • Set ordering
  • Set navigation items of the topnavigation manually via xml
  • Add parent site to the quicklaunch if it exist

donderdag 14 juni 2012

SharePoint 2010: Create a custom wiki page

How to create a custom wiki page in SharePoint 2010 with a simple FeatureReceiver?


With this code it's pretty easy:

private string wikiFullContent = string.Empty;

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPWeb web = properties.Feature.Parent as SPWeb)
{
//* Define page payout
wikiFullContent = FormatBasicWikiLayout();
//* Add page to library
SPList sitePages = web.Lists.TryGetList("$Resources:core,WikiLibDefaultTitle;");
if (sitePages == null)
{
sitePages = web.Lists.EnsureSitePagesLibrary();
}


woensdag 13 juni 2012

SharePoint 2010: Restrict web templates

Define which web templates may be available when you create a subsite


In the analysis of a new project was described that the users only a few webtemplates could see when they want to create a new subsite. After some research on the internet I found that it is possible to define that via the UI of SharePoint 2010:

Site Actions -> Site Settings -> Page layouts and site templates

(default)

(after the selection)



In this settings page you can define which web templates you set available but that's not a solution on the question of the analysis. You can't ask to each contributor to set this setting by themself so I wrote a featureReceiver and via featureStapling I hang to the defined site templates.
Important! If you want to do this via code be sure that the Publishing Infrastructure and Publshing Feature is activated!

dinsdag 12 juni 2012

SharePoint 2010: Starter v4.master without tables

Starter v4.master with div tags instead of table tags

Standard is the default masterpage of SharePoint (v4.master) build on tables. Every designer knows that tables only bring troubles so I desided to convert all the tables to div tags.

Via the link below you can download the result.


Enjoy it!

SharePoint 2010: Show the parent site in the breadcrumb

How to show the parent site in the breadcrumb of your custom masterpage?

By default there is a masterpage that has this configuration. You can find this in the default nightandday.master.

What needs to be done to have this in your custom masterpage?

Add following code to in the <div class="s4-ca"> tag:

<!-- Breadcrumb with parent site -->
<div class="breadcrumb">
  <asp:SiteMapPath
   runat="server"
   SiteMapProviders="SPSiteMapProvider,SPXmlContentMapProvider"
   RenderCurrentNodeAsLink="false"
   NodeStyle-CssClass="breadcrumbNode"
   CurrentNodeStyle-CssClass="breadcrumbCurrentNode"
   RootNodeStyle-CssClass="breadcrumbRootNode"
   HideInteriorRootNodes="true"
   SkipLinkText="" />
</div>

The css here defined contains the default style of the v4.master headbreadcrumb.

maandag 11 juni 2012

SharePoint 2010: Custom Site Definition

Failed to instantiate file "default.master" from module "DefaultMasterPage"


Today I got this error while trying to create a new Site Definition in SharePoint 2010. It turns out that the TemplateName you select in your webtemp_custom.xml file:

<Template Name="CustonSiteDefinitions" ID="10000">

Must match the folder in your SiteTemplates directory:

14/TEMPLATE/SiteTemplates/CustomSiteDefinitions