CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

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=14.0.0.0,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"
	Url="Cars.aspx"
	Type="GhostableInLibrary">
  <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">
	<![CDATA[
	   <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
		  <Assembly>Microsoft.SharePoint, Version=14.0.0.0,
				Culture=neutral, PublicKeyToken=71e9bce111e9429c
		  </Assembly>
		  <TypeName>
			Microsoft.SharePoint.WebPartPages.ContentEditorWebPart
		  </TypeName>
		  <Title>About cars</Title>
		  <Description>Test</Description>
		  <FrameType>None</FrameType>
		  <IsVisible>true</IsVisible>
		  <Content
			xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
				Lorem ipsum dolor sit amet
		  </Content>
		  </WebPart>
	   ]]>
  </AllUsersWebPart>
</File>

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"
    Url="$Resources:cmscore,List_Pages_UrlName;"
    Path="">

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

<%@ Page Inherits="Microsoft.SharePoint.Publishing.TemplateRedirectionPage,
   Microsoft.SharePoint.Publishing,Version=14.0.0.0,
   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.

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

Вула Чăвашла

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

Discovering SharePoint

And going crazy doing it

Bram de Jager talking Office 365, SharePoint and Azure

My view and thoughts on Productivity and more.

My programming life

and everything in between

SharePoint Development Lab by @avishnyakov

It is a good place to share some SharePoint stories and development practices.

SharePoint Dragons

Nikander & Margriet on SharePoint

Paul J. Swider - RealActivity

RealActivity is a specialized healthcare services and solution advisory firm.

Mai Omar Desouki - Avid SharePointer

Egyptian & Vodafoner - Senior SharePoint Consultant

Cameron Dwyer | Office 365, SharePoint, Outlook, OnePlace Solutions

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

paul.tavares

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

SPJoel

SharePoint for everyone

SharePointRyan

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, ya mama

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint

%d bloggers like this: