Skip to content

How to pull a custom column into a Page Layout in SharePoint 2010

by on June 22, 2011
  1. Open your page layout in SharePoint Designer
  2. In the toolbox > server controls > drag and drop ListItemProperty to desired location (I prefer code view for accuracy>
  3. You should have something like the following: <SharePointWebControls:ListItemProperty runat="server" id="ListItemProperty1" />
  4. Add Property value using desired property name – this is where it can get complicated
    • If you have spaces in a custom field use “_0x0020_” to represent the space
    • If you are pulling secondary lookup fields, the colon is represented by “_x003a_”
    • If you are using a core SharePoint field/property you will need to find the correct property name in documentation. About the only thing named what you would expect is Title (“Title”) so you can use this as a test property. Reference

Examples

Below is an example of a final property tag where the column name is “MyColumn

<SharePointWebControls:ListItemProperty runat="server" id="CustomListItemProperty" Property="MyColumn" />

 

Below is an example of a final property tag where the column name is “Associated Document:Link Title

<SharePointWebControls:ListItemProperty runat="server" id="CustomListItemProperty" Property="Associated_x0020_Document_x003a_Link_x0020_Title" />

Using lookup custom properties to build a link

Now we can do something fun, like pull in a link from custom columns in another list:

<a class=”associated-document-link” target="_blank" href='<SharePointWebControls:ListItemProperty runat="server" id="ListItemProperty1" Property="Associated_x0020_Document_x003a_LinkUrl" />’>
<SharePointWebControls:ListItemProperty runat="server" id="ListItemProperty2" Property="Associated_x0020_Document_x003a_Link_x0020_Title" /></a>

Here we are pulling the Link Url and the Link Description from the Documents library based on the associated document selected by the user in a custom lookup field in the page settings. These additional custom fields are then used to build a link to the document which opens in a new window.

Note: to get the path url you need to create a workflow to put the link in a custom field in the Documents library – in this case it is called “LinkUrl”. Once it is in a custom field, the column can then be pulled in to another list.

The benefit of this is that when the document changes, or the title/description changes on the associated document, it will change on every page which references it in the site. You have just saved an hour or more of editing for yourself.

A simpler way would be to just have the link open in the same window – in which case just a link property/field could be created in the Pages Library. I would only use this if I was referencing another site page with navigation on it, so as not to lose the viewer. The link url, in this case called “DocumentUrl”, would be easily referenced as in the following example:

<SharePointWebControls:ListItemProperty runat="server" id="ListItemProperty1" Property="DocumentUrl" />

Advertisements
One Comment
  1. Thanks for the post! This was a huge help to me in figuring out how to display a lookup field value without the hyperlink. This stuff isn’t documented all that well so was fortunate to find your blog.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: