Posts

Showing posts from September, 2012

Getting Page Field Value in custom publishing page layout

I wanted to create a custom publishing page layout which should render certain UI elements based on the page metadata. For e.g. a page metadata field called "Page Type" being used to display different links on pages (created with the page layout). Surprisingly, first step in the process i.e. reading the page field using SharePoint Javascript API proved to be rather painful as my good friend google wasn't willing to put it on my plate. Finally came up with some code to get this done so sharing below:---- Include this code into your custom publishing page layout to query page metadata fields within the layout: /**************************************************************************************/ var pageItem; //variable for list item of page being displayed (which uses this page layout) var pageFieldNameVar = '[internal name of a custom page field]' ; //variable for page field to be retrieved var context; // This variable will cont...