Monday, September 10, 2007

Create custom Web Part page template in MOSS

I recently developed a crafty list based custom navigation provider in MOSS that shows custom nav for the global navigation and the current site navigation. We are also working on SharePoint governance in our company and are encouraging users to create meaningful landing pages to surface links to documents instead of just creating sites and going straight to document libraries.

The requirement is that the current navigation also be available on Web Part pages, since it does not appear on there by default because the default Web Part page is meant to really hold more content and not so much navigation. So I had to create a custom page from spcf.aspx file and rename it Customspcf.aspx. I added my custom link in create.aspx to call Customspcf.aspx for creating new Web Part pages. Then I browsed to the \12\TEMPLATE\1033\STS\DOCTEMP\SMARTPGS folder and tried to add my new custom page there. I reset IIS and my new Web Part custom page did not show up in the Customspcf.aspx page (it only showed the default 8 page layouts).

I played around with it a little bit and here is my conclusion. Unless I understand this wrong, MOSS does not allow you to add custom Web Part page layouts to the 8 already pre-configured layouts. In order to add one, you must replace one of the existing layouts with yours. Bummer!!

So I did exactly this to the spstd1.aspx layout. I also went ahead and removed this line <asp:content runat="server" contentplaceholderid="PlaceHolderLeftNavBar"></asp:content>, which basically overrides the left nav placeholder content from the master page with nothing. The left navigation then showed up on the custom Web Part page!!!!

I also went ahead and removed the footer Web Part zone from the spstd1.aspx file as well as changed the width of the left zone to be 70% of the available area. This gives us more space to insert Content Editor Web Part and make the Web Part pages behave more like traditional pages with navigation on the left, content in the center and some links on the right.

TIP: Try not to change create.aspx using SharePoint Designer. You will most likely get an error 'The file '/_layouts/_layouts/application.master' does not exist. at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath) .....'