Wednesday, June 11, 2008

Layout pages for WSS 3.0

The Windows Sharepoint Services 3.o comes with "8" default "Web part page layouts".
If your pages does not fit into these layouts, then you have to go for "Custom page layouts".

By default, WSS wont allow you to have any more page layouts other than these out of the box page layouts. There is small tweaks need to be done, in order to accomplish your page layout to get listed in "spcf.aspx" or you can have your own "custspcf.aspx" page which lists your page layouts.

Here is how i did it.

There are three simple steps to be followed. Those are

1. Creating additional layout pages.
2. creating a custom spcf page (which lists out your page layouts.. I will tell you why..you have to go for the custom one here )
3. Adding a link in the create.aspx page ( which directs you to custspcf.aspx page)


1. Creating Additional Page Layouts

For the Demo am copying one of the existing page layouts.
The Page Layouts are located in the drive
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\STS\DOCTEMP\SMARTPGS"

You can copy one of these and save it as "spstd9" (there are already 8 built in templates in this folder).

The image [This is to show how your page layout looks like] that gets displayed in spcf ( or custspcf.aspx) comes from the "_layouts\images" folder. So you need to store the image corresponding to the page layout in that purticular folder

( Note :
"_layouts\images" folder maps to "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\template\images" in IIS).

Important thing here is "The name of the image should be same as the name of the page layout.
Eg if the name of page layout is
'spstd9.aspx' then name of image should be 'spstd9.gif' "


2.
Creating a custom spcf page

First lets understand..
why not use the spfc.aspx itself?
The built in spfc.aspx page makes use of "OWSSVR.DLL" which is located in "\12\ISAPI\" folder for its processing. Its shielded to us and hence the functionality cannot be altered...
(Actually, the spfc.aspx passes the parameters to the dll as a query string, may be its possible to achieve the functionality by appropriate query parameter. But, a more research is required here.. May be some one can pen on this).

So.....
lets build Custspfc.aspx page
This application page is give by Microsoft for wss 2.0 and works for wss 3.0 as well.. You can download the page from here.



Open the page and navigate to code snippet
See the option values and if you want to add one more page layout add one more row and give the page layout name as value, and increase the size to 10. That's all, you add as many layout pages as you wish,by this way.






Save the
Custspfc.aspx in "_layouts" folder ("C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS")



3. Adding a link in the create.aspx page ( which directs you to custspcf.aspx page)

Now, we have come to the last step .
open the "create.aspx" page from "_layouts" folder. Search for the code





below that add a link to "custspcf.aspx"



This will create a link in your create.aspx page from which you can go to "custspcf.aspx" page.. (http://machinename:port/_layouts/custspcf.aspx)
Thats all.... Go and browse your site and create pages using your own page layouts.

16 comments:

Anonymous said...

how do u get the spfc page to work without using these custspfc page..

Anonymous said...

Excelent post, but i would like to use this to add custom webpart pages to a document library.

How do you get this in moss 2007?

Droed said...

This doesn't seem to work completely. I get errors when trying to modify create.aspx and when choosing a template the image splats. Any suggestions??

Anonymous said...

Nice post,
will you please let us how we can add custom quick launch by default to this template.
i.e. when you create new layout then customize quick launch will appear in new layout

Raghavendra K said...

@ Bubba
You don't need to alter anything in the Create.aspx. I just wanted to put a link in this page so as to navigate to that particular application page(custspcf.aspx).

The alternative could be is to create a feature which in turn creates a link in SiteSettings and will help you to navigate to that page.

Raghavendra K said...

@bart

Hope i got ur Question :)

Create a Dosument Library and choose the Default template as WebpartPage.

So whenever you choose New option in Document Library that will navigate to "spcf.aspx" page.

Here what we want is to navigate to url "custspcf.aspx" .
So what workaround we can do here is "have a javascript or meta tag" which automatically redirects you to custspcf page.

Anonymous said...

Just what I needed, thanks!

@bart and raghu

There's a much neater method of achieving this (in WSS at least).

1. Create a new Site Content Type called "Custom Web Part Page" which has "Web Part Page" as its parent.

2. Edit the "Custom Web Part Page" content type and change the url of the document template to "/_layouts/custspcf.aspx" (advanced settings).

3. Add the "Custom Web Part Page" content type to the document library and set as default. You may need to turn content type management on for the list beforehand.

Now "Custom Web Part Page" will be on the "New" menu and will create new web part pages from the customised custspcf.aspx

Raghavendra K said...

@Grims
Thanks Grim, The method which you suggested is the proper way.

Anonymous said...

using the approach that was mentioned by you, How can we enforce the changes to be applied in the child pages?

Is there a way to do that in WSS?

Thanks

Anonymous said...

Great Post, much better than the MS instructions (which they've pulled down :)

This page actually has the custspcf.aspx code...

http://www.mindsharpblogs.com/PaulS/archive/2008/08/19/7488.aspx

You might still look at the google cache for the original MSDN page...

http://74.125.77.132/search?q=cache:LSPN4h6AEF0J:msdn.microsoft.com/en-us/library/ms916835.aspx+http://msdn.microsoft.com/en-us/library/ms916835.aspx&cd=1&hl=en&ct=clnk&client=firefox-a

fijaz said...

When i try to create a page based on my Custom layout (which is a copy of one of the existing page layouts) it gives me an error.

Invalid URL Parameter

The URL provided contains an invalid Command or Value. Please check the URL again.

EB said...

Hi, and tanks for this good post.
I've the same problem as Fijaz - Any idea ? Fijaz, have you find a solution ?

Badee said...

I can't download the Custspfc.aspx page. please can you provide us with a link..

Thanks for your time...

Custom Papers Writing said...

Many institutions limit access to their online information. Making this information available will be an asset to all.

Marketing Dissertation topics said...

Nice article, i appreciate for putting this together! "This is obviously one great post. Thanks for the valuable information and insights you have so provided here. Keep it up!"
Marketing Dissertation

Marketing Dissertation topics said...

Nice article, i appreciate for putting this together! "This is obviously one great post. Thanks for the valuable information and insights you have so provided here. Keep it up!"
Marketing Dissertation