Custom Publishing Page Layout using SharePoint Designer - SharePoint Development & Administration + InfoPath

Tuesday, September 15, 2009

Custom Publishing Page Layout using SharePoint Designer













Overview:
This article demonstrates how to create a customised Publishing Page Layout which can be used to add publishing pages to a SharePoint site with publishing features enabled. The page will be created from a content type which contains additional fields which are to be displayed on the publishing page both when it is being edited and once it has been published. This article also demonstrates how to display fields only when a publishing page is being edited using an Edit Mode Panel if required.








1. Activate Publishing Features on the SharePoint site:
2. Create Publishing Layout Content Type
3. Create Publishing Layout from the Content Type
4. Customise the Publishing Layout using SharePoint Designer
5. Add the Content type to the Pages library on the SharePoint site
6. Create a new Page from The Custom Publishing Layout

Requirements:
  • SharePoint (MOSS 2007)
  • SharePoint's Publishing Features
  • SharePoint Designer (2007)
SharePoint Designer is now available for Free. Download SharePoint Designer from the Microsoft Website.


1. Activate Publishing Features on the SharePoint site:
Publishing features need to be enabled on the SharePoint site which uses the features. To ensure that publishing features are enabled, you can either create the SharePoint Site from the News, or Publishing Site templates, which have publishing features enabled, or enable the Publishing Features on an existing site in the site collection.

Check the status or enable/disable the Publishing Features on a SharePoint site:
  1. Go to the Site Settings page of the SharePoint site
  2. Select Site Features, located under the "Site Administration" heading.
  3. Enable Publishing Features if required.






Enabling Publishing Features on a SharePoint Site will:
  • Create a Documents, Images and Pages library to be used when creating publishing pages on the site. The Documents and Images libraries are used to store files or images which are uploaded when creating content using a Publishing Page Layout. The upload dialog allows a user to easily select the Site Collection Images library, or the current (Publishing) site image library for an image to be uploaded for use in a Publishing Page Layout.
  • Add the "Create Page" and "View All Site Content" options to the "Site Actions" menu of the site.

2. Create Publishing Layout Content Type
When creating or customising a publishing layout which is in an article format which has common fields that the OOB "Article Page" content type such as start and end dates, article title, body, audience, etc., it may be quicker to create the custom Publishing Layout Content Type from the Article Page content type. If you require a custom set of fields on the publishing page, create the content type from the "Page" content type which is a core component of the publishing feature provided by SharePoint.

Process:
- Create the Initial Content Type
  • Browse to the Content Type Library at the Site Collection root, or the content Type Library of the site which will use the Publishing Features.
  • Site Settings -> Site Content Types (under Galleries heading)










  • Select "Create" to add a new Content Type.














  • Enter a name for the content type and description if required.
  • Select the "Article Page", or "Page" Publishing Content Types. If you are creating a news article like page layout, it may be more efficient to create a custom Article Page and modifying to suit rather than starting from scratch.








- Add Additional Columns/Fields to the Content Type if required
  1. Additional metadata fields can now be added to the Publishing Layout Content Type if required, by following the same procedure as you would to add a field to any Content Type in SharePoint.
  2. Open the Content Type if required by selecting it from the content type library
  3. Select "Add from Existing Site Columns" if the additional metadata fields/columns are already available on the current SharePoint site, or select "Add from New Site Column" to create a new column.
In this example I have created an additional column called "Audience", which is a choice field with two options; Internal and External (Below).


















3. Create Publishing Layout from the Content Type
Once the Publishing Layout content Type has been created, a Publishing Layout can be added to the Materpage library by selecting the custom content type created in Step 2 from the options available when creating a new Masterpage or Page Layout.

Process:
  • Browse to the Site Collection Masterpage Library, or the Masterpage Library on the site which the Publishing Layout Content Type was added to in Step 2 if not the Site Collection root.












  • Press the "New" button on the Masterpage Library.
  • Select the Publishing Layout Content Type created in Step 2 from the list of options.
  • Give the Publishing Layout a short, but descriptive title, as this will be used to destinguish the Publishing Layout from others when selecting from the available options.









  • Press Ok to create the Page Layout.

4. Customise the Publishing Layout using SharePoint Designer
Once the Publishing Layout has been created from the content type containing the custom fields, it can the be opened using SharePoint Designer and modified as required. Additional fields from the Publishing Layout Content Type can be added to the layout to be displayed when the page is checked in or published. If a metadata field is required for the Publishing Page Layout, but does not need to be visible on the page once it has been published, Edit Mode Panels can be used to display the containing fields only when the page is being edited.

Process:
  • Using SharePoint Designer, open the Publishing Layout from the Masterpage Library created in Step 3, or select "Edit Using SharePoint Designer" if available on the Edit Menu of the custom Publishing Layout.

















  • Apply the required layout and formatting to the publishing page by creating empty regions/cells where content fields will be placed.
  • Open the Toolbox - Task Panes -> Toolbox
  • From under the Page Fields and Content Fields Headings, drag the required fields into the empty regions on the publishing page.





















CSS Styles
You can set the styles for content field elements on a Publishing Page using the "Tag Properties" task pane. Set the CSS class of the element to a class which has been set up to format display the element as required (See Below).




















Edit Mode Panels
In a Publishing Page Layout, fields inside an Edit Mode Panel not be visible when the page is not being edited. This allows metadata fields which are required for each publishing page to be added to the layout, but not displayed in the publishing page once checked in, or published as a major version.

How to Add an Edit Mode Panel to a Page Layout:
  • Open the Toolbox - Task Panes -> Toolbox
  • Under the Server Controls heading of the Toolbox in SharePoint Designer, drag the "EditModePanel" control into the required region of the publishing page.


















  • If using the code view only, the EditModePanel control can be added to the page by dragging the control into the required section of code, or by right clicking the control in the toolbox and selecting "Insert".
  • Add publishing layout field elements to the Edit Mode Panel by dragging the required content field into the Edit Mode Panel.
  • If using the code view only, add the content field tag to the Edit Mode Panel tag (See Below)













5. Add the Content type to the Pages library on the SharePoint site
Add to the list of available Page Layouts when creating a new page from a Publishing Page Layout, to include the custom Publishing Page in the list of options.
  • Browse to the Pages library of the SharePoint Publishing Site













  • Open the settings page for the Pages Library
Settings -> Document Library Settings









  • Select "Add from existing site content types".
  • Choose the Publishing Layout Content Type created in Step 2





  • Press Ok.

6. Create a new Page from The Custom Publishing Layout
A new page can now be created from the custom Publishing Page Layout by pressing the new button on the Pages library. Give the page a name and description, then select the Page Layout from the list of options and press the "Create" button to create the page.
















Once the page is Checked in or Published after it has been edited, it can be viewed in a browser by opting the address/URL to the page in the browser, or by selecting the page from the Pages Library of the publishing site.

Share this article:
Stumble This Delicious
Delicious
submit to reddit
Facebook
MySpace
MySpace

5 comments:

Karuana Gatimu said...

Thank you for writing this. I know the steps but its very helpful to have it all laid out with screen shots etc. I posted a link to this article on my blog, SharePointStrategist.com. Thanx again!

DanielS said...

No problems, glad I can help.

Thanks for the link.

Daniel

kesav7902 said...

g8 post....

JUNDI said...

Hi Daniel,

I would like to know if it's possible to add page rating abilities (star rating and Comment box control) to a sharepoint publishing page layout.
my email is hmjundi@hotmail.com

Much Appreciated

DanielS said...

Hi JUNDI,

MOSS 2007 doesn't have OOB rating abilities as such, but this functionality can be replicated using a custom field that stores numeric data (decimal).

You could possibly add the star rating to a publishing layout using radio button controls for the field that correspond to a rating value (ie. 1-5), then use CSS and/or JavaScript to format and style the controls as required.

The following article by Shai Petel explains how to add a rating field to content in SharePoint: Add Content Rating to MOSS Search Results

Post a Comment