views:

919

answers:

2

I have a SharePoint feature that installs a new page layout.

A requirement for this feature was to install the page layout with a default web part, so that when the user runs through the 'Create Page' action, the page is created with a web part already on the page.

So, I've tried adding a AllUsersWebPart node in the Elements definition of the page eg.

<Elements>
    ...
    <Module ...>
     ...
     <File ...>
      <AllUsersWebPart ...>
       ...
      </AllUsersWebPart>
     </File>
     ...
    </Module>
</Elements>

Installed, deployed the feature etc and of course got the helpful 'No parameterless constructor defined for this object' error - a problem with my definition in the Elements.xml most likely.

Now the REAL problem I've got is that I've tried deleting the AllUsersWebPart section from the feature definition (so that the page has no web parts on it when created) and, due to a fantastic bug in SharePoint, the web part is still left defined for the page layout, even though the feature definition says differently - I found some details about this on http://sharepointblog.buus-oestergaard.dk/post/Default-webparts-in-sharepoint-pagelayouts.aspx (Point #2).

I've tried upgrading & removing / re-installing the feature but to no effect - how can I remove this web part from the feature / content db so that I can have the feature just install the page layout or put the correct web part definition in the feature?

A: 

When uninstalling the feature, did you make sure that your pagelayout is deleted from the Masterpage/pagelayout catalog?

The feature element used for adding the content file (pagelayout) does not remove it when deactivating the feature.

Thomas Favrbo
Yes, but that didn't make any difference. It looks like SharePoint adds the info in the AllUsersWebParts to the content db but doesn't update it correctly with updated info..
marcus.greasly
A: 

Ok, I got my page layout working, these are the steps I took in case this is useful:

1 Edit the page layout in web part page maintenance mode:

http://&lt;server name>/_catalogs/masterpage/<page name>.aspx?contents=1

Delete all web part instances from there.

2 Open the layout (on the server) in Designer, & make sure the WebPartZone / ZoneTemplate s are empty. Make sure the page layout is set to approved after checking this.

The page layout is useable after this - I was able to remove & re-install my page layouts feature without any problems.

It looks like the web part definitions are left in the database so that when a feature is updated/re-installed, they are already there linked to the page / web part zone. Sorting this out should probably be being done in code in a feature reciever in the page layout feature, if I ever get around to writing this I'll post it somewhere...

marcus.greasly