Monday, June 4, 2012

Delete a Page Layout

I wanted to delete a Page Layout that I had deployed thru feature and used here and there already. The reason was that I became wanting to attach a preview image of my own to it. Thought it should be straightforward. A small modification to the feature. But it turned out not...

http://social.msdn.microsoft.com/Forums/en/sharepointecm/thread/273ef6a0-1f9f-46d8-9e9f-a70f81bc79cc

People here appear to have the same problem and discuss that the only solution is to delete the provisioned layout once and re-activate the feature.

But to delete a layout is not easy. Obviously I need to make sure it is not used by any page. I did that, by writing some code to list all pages using the layout and replacing with other layout. But still cannot. The famous “This item cannot be deleted because it is still referenced by other pages” message continues. It could be that the layout being not used by any page is not enough. Other places such as sites configured to have it available may need to be taken care of too, which I may have a closer look in future when I find time.

http://sharepointcodeblock.blogspot.com/2008/06/deleting-page-layout-or-master-page.html

In the meantime, I tried this too but no luck. Then realized that once I have moved it to a subfolder, even though I cannot delete it still, I can provision the new one, with my preview image. Not beautiful that the old one is always sitting in the subfolder, but at least I guess I have achieved what I wanted.

One more thing. I would like to keep this link as well for possible future reference.

http://blog.mastykarz.nl/provisioning-publishing-pages-features-declarative-markup/

Where I found the name of the feature which deploys the OOTB Publishing Page Layouts. Only by looking into it, I was able to find the name of the property (turned out to be “MasterPageDescription”) for the description (not very visible. appears for instance on _Layouts/CreatePage.aspx).

No comments: