Working with Display Templates with the new PnP Provisioning Core Engine

Following on my theme of catchy blog titles that aim to do exactly what they say on the tin, I am going to walk through how you would take a copy of an existing display template xml reference (found in the elements xml of your display template module) and amend it to comply with the PnP schema, so that it works with the provisioning core engine and you can put it in your own PnP template file.

First of all, if we take a look at how the display template file it is represented declaratively in xml, within the module (elements xml file). Take a look at the following example:

So the first thing we need to do is to copy this into a new file and then add the ‘pnp:‘ prefix at the beginning of each node. Then we need to change the Path attribute in the File node to Src.

Add a new attribute called Folder which contains the relative path to the folder that the display template will need to go in the master page gallery (it usually looks something like _catalogs/masterpage/Display Templates/Search). Note that you need to leave the slash character off the beginning and end of the value.

Once this is done, we need to remove the Url, Type, Level and ReplaceContent attributes from the file node.

Now we need to remove all ‘Type’ attributes from the property nodes and change the Name attribute to Key.

After this, ensure that all of the property nodes are wrapped in a single ‘pnp:Properties‘ node.

Finally, once all of this is done, we need to ensure the following nodes are not present (delete them if they are):

  • Name
  • Description (you can rename this one to MasterPageDescription where necessary)
  • HtmlDesignAssociated

Once all of this is done, we end up with something like the following:

For more in depth guidance on the Remote PnP Provisioning Schema, take a look here:

Working with Display Templates with the new PnP Provisioning Core Engine
Tagged on:         

Leave a Reply

%d bloggers like this: