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.