ContentPlaceHolders and SharePoint 2013 Page Layouts

Having problems today working with overriding ContentPlaceHolders in the brave new world of HTML and Master Pages/Page Layouts. Firstly how to add the content place holder into the Master Page into a place that SharePoint will utilise it and not put it into the bottom of the page.

To do this you need to add the following to the HTML Master Page in the HTML where you want the PlaceHolder to sit:

<!--CS: Start PlaceHolderUtilityContent Snippet-->
<!--SPM:<%@Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>-->
<!--MS:<SharePoint:AjaxDelta ID="DeltaPlaceHolderUtilityContent" runat="server">-->
<!--MS:<asp:ContentPlaceHolder ID="PlaceHolderUtilityContent" runat="server">-->
<!--ME:</asp:ContentPlaceHolder>-->
<!--ME:</SharePoint:AjaxDelta>-->
<!--CE: End PlaceHolderUtilityContent Snippet-->

SharePoint will recognise this and not put the ContentPlaceHolder as empty at the bottom.

So how do you add content into this in your HTML page layout. Just add an override right? e.g.

<!--MS:<asp:ContentPlaceHolder ID="PlaceHolderUtilityContent" runat="server">-->
<div>someothercontent</div>
<!--ME:</asp:ContentPlaceHolder>-->

Well this will not work. What you have to do is tell the page that the ContentPlaceHolder is being utilised in the Page Layout. This is done in the <mso:CustomDocumentProperties> sections. You need to add two properties firstly (Below the equalivant for Place Holder Main):

<mso:ContentPlaceHolderHashPlaceHolderUtilityContent msdt:dt="string">1</mso:ContentPlaceHolderHashPlaceHolderUtilityContent>

Secondly:

<mso:ContentPlaceHolderChangedPlaceHolderUtilityContent msdt:dt="string">True</mso:ContentPlaceHolderChangedPlaceHolderUtilityContent>

Now your override will work!

Comments

Post a Comment