Saturday, March 29, 2014

SharePoint 2013 Display templates

Creating custom display templates in 2013 using visual Studio 2012

To create a custom display template using VS2012, add new item and select "Module" template
and in its "element.xml"  have below markup.

<Module Name="DisplayTemplates" Url="_catalogs/masterpage">
<File Path="DisplayTemplates\TemplateName.html" Url="Display Templates/Content Web Parts/TemplateName.html" Type="GhostableInLibrary" /> 
</Module>

Referencing custom CSS files in display templates in the body section as below
<script>
$includeCSS(this.url, "_layouts/15/1033/Styles/CustomCSSName.css");
</script>