Sandbox Solution : Provision publishing page

Last year while working with sandboxed solution for SharePoint 2010, i faced a problem while creating a module to provision publishing pages with WebParts.

Problem :

I used this code :

module

 

 

 

 

I added this module on a feature, but when i activate the feature i get :

  1. The page is draft
  2. The WebPart is not added.

Solution :

This approach assume that the file “page.aspx” will be copied on the 14 folder on the feature folder. However SandBoxed solutions do not have access to root folder.

The solution is to use a file which is already on the SharePoint root folder :

sandboxModule

 

 

 

What i changed is the “SetupPath” , this property is used to specify a physical path to a folder that contains a file to include on the module.

I will use the file “SiteTemplates\SPS\default.aspx” so i set SetupPath to “SiteTemplates\SPS” and the Path of the file to “default.aspx”.

And now everything is working fine 🙂

 

Advertisements

One thought on “Sandbox Solution : Provision publishing page

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