Friday, February 15, 2008

Creating a Page Layout

Note: Paths are referencing the root of the 12 hive

1. In Visual Studio, add the .aspx file to /TEMPLATE/FEATURES/Project.Page Layouts/.

2. Under Site Settings → Galleries, select Site content types.

3. Create a new Site content type for the page layout. The Parent Content Type should be “Page” from “Publishing Content Types”.

4. After it’s created, grab the content type ID from the URL on the Site content type page (it’s the URL parameter that looks like this: 0×010100C568DB52D9D0A14D9B2FD1983DD007948)

5. Under Provisioned Files in the Page Layouts directory, copy a File node in the Module “New Page Layouts”—place it at the top of the list.

6. Edit the following property:

      

Substitute the “Level 2” for the Content Type Name and the 0×010… with the content ID that you just created.

7. Run stsadm to install (if the first time) and activate the Page Layouts feature.

stsadm -o installfeature -name Project.PageLayouts -force

stsadm -o activatefeature -name Project.PageLayouts -url "http://project.com" -force


Deleting Page Layouts

This has got to be my favorite bug (feature? : ) of SharePoint so far. You'll run into an error telling you that the PageLayout is attached, delete all references etc etc. BUT, there is an easy workaround.

Simply open up Designer, make a new folder named "delete" in the same directory, cut the page layout(s) you'd like to get rid of, paste them in the delete folder. And then delete the folder.

Easy as that. But not quite as easy as deleting via the browser!

Creating a Site Template

The following details the necessary steps to create a site template. Note that all paths are referencing the start of the 12 hive (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12)

1. Under /TEMPLATE/1033/XML/webtemp_project.xml, add a new template:

  

Note that DisplayCategory is the tab that the site templates will reside in -- great
for separating for different projects.

2. Go to /SITETEMPLATES/PROJECT/XML/onet.xml, under Configuration node, make a new node, change ID to match the ID for the configuration.

3. Modify the Content Type Provisioning that the default page of the site should be.

4. Add a new module which will define the page layout of the default page.

5. Create the content type (inheriting from Page) and get the Content ID? (ctype) and put it in the onet.xml file.

6. Create ASPX page layout for the site template (if necessary).

Error: The security validation for this page is invalid.

If you get the following error:

"Error: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again."

You can fix it by:

1) Opening up Central Administration
2) Select Application Management
3) Under Web Application Settings, Security Validation, set it to off.