CHunky Universe of Vigourous Astonishing SHarepoint :)

Tag Archives: onet.xml

Show files first in view

When you create an own view in schema.xml it is easy to show files first (Scope). It is quite useful if you want to show only few items on start page in xsltlistviewwebpart:


Though there is a problem when you provision this list instance. Thanks to a great post of Koen van der Linden about how to show files recursively it is no big deal to solve it. Just add the same scope to View element in the module in onet, which provisions your site:

<View List="$Resources:core,shareddocuments_Folder;" 
     BaseViewID="41" WebPartZoneID="Middle" WebPartOrder="2" Scope="Recursive" />

One shortcoming of this method is that fact that you cannot change the view in you (xslt)listviewwebpart. Well, actually, you are able to change the view, but the scope=”recursive” property is still there, so you probably don’t see the difference because the the scope property is hard coded into xsltlistviewwebpart in the onet.xml.

Provisioning multiple pages with one source file

I found an easy way to provision multiple pages. Create a module. Add an aspx.file (e.g. default.aspx). In the elements file define nodes for every page. Path should be the same for all pages, but the Url should be your destination page.

The “default.aspx” (name doesn’t matter) can contain content, or just one @Page directive if Publishing feature is available:

<%@ Page Inherits="Microsoft.SharePoint.Publishing.TemplateRedirectionPage,Microsoft.SharePoint.Publishing,Version=,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>

In the Element.xml define all your pages:

In every File node you can add webparts, here is an example:

<File Path="ABunchOfPages\default.aspx"
  <Property Name="Title" Value="About cars" />
  <Property Name="PublishingPageLayout"
		Value="~SiteCollection/_catalogs/masterpage/MyLayout.aspx, Text page" />
  <Property Name="ContentType"
		Value="$Resources:cmscore,contenttype_welcomepage_name;" />
  <AllUsersWebPart WebPartZoneID="Top" WebPartOrder="2">
	   <WebPart xmlns="">
		  <Assembly>Microsoft.SharePoint, Version=,
				Culture=neutral, PublicKeyToken=71e9bce111e9429c
		  <Title>About cars</Title>
				Lorem ipsum dolor sit amet

Of course we could do it in the onet.xml file, but in this case I wanted to show how to do it with an additional module. It is a good way to control the content which is provisioned. And your onet.xml is not so big.

The last thing is to add a web scoped feature which will have this module and add the new feature reference into a site configuration (SiteFeatures section) in the onet.xml.

In this example we provision pages to Pages library ($Resources:cmscore,List_Pages_UrlName;):

<Module Name="ABunchOfPages"

Inside SharepointIt works fine to use our default.aspx with redirection directive (TemplateRedirectionPage):

<%@ Page Inherits="Microsoft.SharePoint.Publishing.TemplateRedirectionPage,
   Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>

But what if we want to save these pages in a different location? Perhaps use the same url as the module name (ABunchOfPages). Inside Sharepoint describes how to do this. When you deploy the module with the custom url (ABunchOfPages) a new folder in the web root folder will be created and the new pages will be created in this new folder.

The problem is, you won’t be able to use the redirection ability and if you navigate to one of your new pages an unexpected error will be shown.

In the log file there are more details:

System.NullReferenceException: Object reference not set to an instance of an object.
	at Microsoft.SharePoint.Publishing.TemplateRedirectionPage.ComputeRedirectionVirtualPath(TemplateRedirectionPage basePage)
	at Microsoft.SharePoint.Publishing.TemplateRedirectionPage.get_RedirectionUrl()
	at Microsoft.SharePoint.Publishing.TemplateRedirectionPage.ProcessRequest(HttpContext context)
	at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
	at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)	92f74450-a50b-416d-9b03-25ef15e3c845

So you have to use another aspx-file to provision your pages. Or you can create another publishing document-library in the same web, although it is not recommended according Microsoft.

Link to Home on Top Navigation Bar

If you have a custom site definition and want to have a link to RootWeb, just add NavBarPage to your module:

<Module Name="OrklaRootBlank" Url="" Path="">
  <File Url="default.aspx">
	<NavBarPage Name="$Resources:core,nav_Home;"
		Url="~site" ID="1002" Position="Start" />

Custom Title on built-in webpart

What to do if you want to change the title in the built-in webpart like Tasks or so. Your own title or just to avoid tasks (1) and tasks (2) if you add two views of them to a page. In onet.xml you add them as view:

  BaseViewID="7" WebPartZoneID="Middle" 

The solution is to add cdata element and webpart tag within it. So now replace this with:

  BaseViewID="7" WebPartZoneID="Middle"
    <WebPart xmlns="">
      Microsoft.SharePoint, Version=, Culture=neutral,
    <Title>Task Title as I want it</Title>

Now you can change the title, and all other properties (chrometype, helpurl and more) as you want. One thing is to mention. If you just copy the onet.xml to the Sharepoint Root (as you can do with CKSDev), you must restart IIS:

iisreset /noforce

Länkar på quicklaunchen

Det är en skum grej: Länkar (listor och bibliotek, kalender och dylikt) visas inte. När jag har ändrat Navigation properties i min konfiguration i onet.xml, då funkar det:

<!-- Navigation Properties -->
<Feature ID="541F5F57-C847-4e16-B59A-B31E90E6F9EA">
  <Properties xmlns="">
	<Property Key="InheritGlobalNavigation" Value="true"/>
	<Property Key="ShowSiblings" Value="false"/>
	<Property Key="IncludeSubSites" Value="true" />
	<Property Key="IncludePages" Value="false" />

HelpUrl i WebPart

Man kan lägga till HelpUrl i en WebPart, för att användare kan klicka och få instruktioner eller hjälp med just denna webpart. För att göra det manuellt, ska man klicka på pilen, välja “modify this web part”, och sedan i “Advanced” skriva url-länken i “HelpUrl”-fältet.

För att lägga till HelpUrl ifrån början, när sajter skapas, måste man ange den egenskapen i onet.xml i Module för din sajt.

Man måste hitta <property>, och ändra den:

<property name="HelpUrl" type="string"></property>

Så ser hela biten ut i onet.xml:

        <AllUsersWebPart WebPartOrder="1" WebPartZoneID="ToolbarZone"><![CDATA[
          <?xml version="1.0" encoding="utf-8"?>
<webPart xmlns="">
      <type name="MySolution.SharePoint.WebParts.Toolbox.Toolbox,
                          Version=, Culture=neutral,
                          PublicKeyToken=bced5ea8e74d1a7e" />
      <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
        <property name="AllowClose" type="bool">False</property>
        <property name="Width" type="string" />
        <property name="AllowMinimize" type="bool">False</property>
        <property name="AllowConnect" type="bool">True</property>
        <property name="ChromeType" type="chrometype">None</property>
        <property name="TitleIconImageUrl" type="string" />
        <property name="Description" type="string" />
        <property name="Hidden" type="bool">False</property>
        <property name="TitleUrl" type="string" />
        <property name="AllowEdit" type="bool">False</property>
        <property name="Height" type="string" />
        <property name="MissingAssembly" type="string">Cannot import this Web Part.</property>
        <property name="HelpUrl" type="string" />
        <property name="Title" type="string">Toolbox</property>
        <property name="CatalogIconImageUrl" type="string" />
        <property name="Direction" type="direction">NotSet</property>
        <property name="ChromeState" type="chromestate">Normal</property>
        <property name="AllowZoneChange" type="bool">True</property>
        <property name="AllowHide" type="bool">True</property>
        <property name="HelpMode" type="helpmode">Modeless</property>
        <property name="ExportMode" type="exportmode">All</property>

Däremot är det svårare att lägga till det i en <View List=”…. Det finns flera sidor (1, 2, 3,  4, 5)som berättar hur man gör det men jag har inte fått det att funka.

Jag har försökt ändra det manuellt och hämta det via Sharepoint Solution Generator (se mitt andra inlägg om det), men egenskaperna för <View List…. hänger inte med då:

<View List="Lists/Courseu20Documents" BaseViewID="0" WebPartZoneID="RightColumnZone" WebPartOrder="2" />

Om man kör på det sättet, så blir det XML-error på sajten man skapar:

<View List="CourseDocuments"  
        <WebPart xmlns="">
            <Title>Pending Registrations</Title>
Daniel Chronlund Cloud Tech Blog

News, tips and thoughts for Microsoft cloud fans

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager - Architect, Speaker, Author

Microsoft 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Mai Omar Desouki

PFE @ Microsoft

Cameron Dwyer

Office 365, SharePoint, Azure, OnePlace Solutions & Life's Other Little Wonders


Me and My doings!

Share SharePoint Points !

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

Aryan Nava

DevOps, Cloud and Blockchain Consultant


SharePoint for everyone


Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint


Mostly what I know and share about...