Lars Nielsen's Discoveries

January 5, 2011

Page layout to show Modified By metadata and version

Filed under: Publishing,SharePoint — Lars Nielsen @ 9:23 pm
Tags: ,

A few times now I have created web sites and Intranet using the publishing features in SharePoint.  I don’t use the Publishing Portal site definition – I just start with a blank site collection and turn on the features that I need (Publishing Infrastructure on the site collection has to be turned on of course).  I also prefer to create my own information architecture even if the built-in content types, site columns and page layouts are adequate.  I create a special content type based on the Article page content type, and then create one or more page layouts to use it.  I keep cutomised elements separate and give them a name prefix so I can easily see what has been customized.

For a page layout I needed to show, automatically on every page, the last person who edited the page, the date it was changed and the version number.  You can do this by including special controls on the page layout file.  Here’s how to do it.

Go to the root site of the site collection.  In Site Settings go to the Master Page gallery.  To make things easier temporarily, you can turn off (in the Document Library settings) content approval, workflows, and require checkout.  That’s assuming the site is not live and you’re the only one working on it.  Just remember to turn all those things back on again before the site goes live.

Open the root of the site collection in SharePoint Designer.  Navigate to the Master Page and Page Layouts gallery (_catalogs/masterpage) and either create a new page layout or edit one you have already created.  Here’s a good description of how to create page layouts in SharePoint.  Open up the .aspx page for the page layout.

In your layout you can add the following markup to show the “Created By” field as the person’s name – and clicking on the name takes you to their profile page:

<SharePoint:FormField ID="FormField1" ControlMode="Display" FieldName="Author" DisableInputFieldLabel="true" runat="server"/>

You can use a similar syntax to extract other data about the page, for example:

Last modified: <SharePoint:FormField ID="FormField2" ControlMode="Display" FieldName="Modified" DisableInputFieldLabel="true" runat="server"/>

Version: <SharePoint:FormField ID="FormField3" ControlMode="Display" FieldName="Version" DisableInputFieldLabel="true" runat="server"/>

You also need to make sure that you have the directive at the top of the layout page:

<%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>



  1. Thanks so much – this is very useful to me

    Comment by Mike — May 19, 2011 @ 10:49 pm

  2. You are awesome!

    Comment by Brett — January 31, 2012 @ 3:23 am

  3. Thanks for the post. Do you have code for “Modified By” instead of Created By?

    Comment by Mavis JC — May 9, 2016 @ 6:52 am

  4. I found it. The code is

    Comment by Mavis JC — May 9, 2016 @ 7:07 am

  5. cannot insert code in my previous comment, but instead of putting FieldName=”Author” , just write FieldName=”Editor”
    Then it will show the last modified person field

    Comment by Mavis JC — May 9, 2016 @ 7:09 am

  6. Thank you for the post. If we use this tag , Time is not as per site collection regional settings. Could you please help to achieve that to display the time based on site collection regional settings?

    Comment by Sathishkumar I.R — October 19, 2017 @ 10:34 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

%d bloggers like this: