SharePoint Development for Beginners: Adding a field to a page layout

Here’s how to add a new field to an existing page layout in Microsoft Office SharePoint Server 2007.

Our current page layout uses the Title field both for the HTML title element shown browser’s title bar and for the header shown in the content. We want to separate these so that the HTML title can be different.

We’ll be modifying the SolienInnerPage.aspx and SolienInnerPageNoLeftNav.aspx page layouts. Here’s an outline of the work we’ll need to do:

  1. Find the associated content type for the page layout
  2. Add a new site column on the content type
  3. Set the column ordering on the content type
  4. Add the field to the page layout
  5. Add content to the new field
  6. Test that the new field’s content is shown on the page layout

1. Find the associated content type for the page layout

image

Both layouts use the Solien Page content type. We’ll add the new column there.

2. Add a new site column on the content type

image

Below the list of existing columns, click “Add from new site column”

image

Set the Column Name and select a group for the column.

image image

Enter a description for the new column.

image

We want to update content types inheriting from this type so that existing items will have the new column available.

image

Once we click OK, the site column is added.

3. Set the column ordering on the content type

On the Solien Page content type, we’ve clicked “Column Order.”

image

We can now set the column order for the new PageTitle column.

4. Add the field to the page layout

Currently our page layout uses the Title field for the HTML title element. We’ll modify it to use the new PageTitle field instead.

First we need to grab a copy of the page layout. In the master page gallery, find the page layout, then select Send To –> Download a Copy.

image

Here’s how the Title field is currently used.

<asp:Content ContentPlaceholderID="PlaceHolderPageTitle" runat="server">

            <SharePointWebControls:FieldValue id="HomePageTitleInHeader" FieldName="Title"

                        runat="server" />

</asp:Content>

Instead, we want to use the PageTitle field.

<asp:Content ContentPlaceholderID="PlaceHolderPageTitle" runat="server">

            <SharePointWebControls:FieldValue id="HomePageTitleInHeader" FieldName="PageTitle"

                        runat="server" />

</asp:Content>

After saving our changes, we’ll upload the new version of the page layout. In the master page gallery, choose Upload –> Upload Document.

image

We’ll overwrite the existing file.

image

Here’s what we see after the page layout is uploaded. There aren’t any property changes needed, so we’ll click “Check In.”

image

5. Add content to the new field

Now that the column has been added to the content type, we can add content on pages that use this page layout.

image

6. Test that the new field’s content is shown on the page layout

It works! Previously the Title field was used,

image

but now the PageTitle field is used instead.

image

 

Want help with your SharePoint implementation, or just need a quick consultation to get things rolling? We’re here to help.


Feedback

No comments posted yet.


Post a comment





 

Please add 2 and 7 and type the answer here: