In the first step, let's create the Authoring and Publishing Site Collections.
Authoring Site collection allows authors to manage their website content while the Publishing Site collection reviews the content from the authoring site collection.
Open the Authoring Site Collection.
Create a list named “menu” that contains title and page URL.


Let’s go and create a control and a template to display the items.
- Control Template
It provides the overall structure (layout) of the HTML elements along with start and end tags.
- Item Template
It renders the items from the list, and contains text and pictures.
Now, let's create two display templates for displaying a bootstrap carousel menu control and a menu item.
Code – Menu Control Template
Upload the script and CSS into style library.

Add the scripts and CSS into Control template.
- <script>
- $includeCSS(this.url, "~sitecollection/Style%20Library/Menu/bootstrap.min.css");
- $includeScript(this.url, "~sitecollection/Style%20Library/Menu/bootstrap.min.js");
- $includeScript(this.url, "~sitecollection/Style%20Library/Menu/jquery.min.js");
- </script>
Now, let's define the HTML layout to the Control Template.
- <nav class="navbar navbar-inverse">
- <div class="container-fluid">
- <div class="navbar-header"> <a class="navbar-brand" href="#">Csharpcorner </a> </div>
- <ul class="nav navbar-nav"> _#= ctx.RenderItems(ctx) =#_ </ul>
- </div>
- </nav>
The full code looks like the following.
- <html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
- <head>
- <title>MenuControl</title>
- <!--[if gte mso 9]><xml>
- <mso:CustomDocumentProperties>
- <mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden>
- <mso:MasterPageDescription msdt:dt="string">Display a menu Item</mso:MasterPageDescription>
- <mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106601</mso:ContentTypeId>
- <mso:TargetControlType msdt:dt="string">;#SearchResults;#Content Web Parts;#</mso:TargetControlType>
- <mso:HtmlDesignAssociated msdt:dt="string">1</mso:HtmlDesignAssociated>
- <mso:HtmlDesignConversionSucceeded msdt:dt="string">True</mso:HtmlDesignConversionSucceeded>
- <mso:CrawlerXSLFile msdt:dt="string"></mso:CrawlerXSLFile>
- <mso:HtmlDesignPreviewUrl msdt:dt="string"></mso:HtmlDesignPreviewUrl>
- <mso:HtmlDesignStatusAndPreview msdt:dt="string">http://technologygeeks/sites/publishing/_catalogs/masterpage/Display Templates/Content Web Parts/banner/bannercontrol.html, Conversion successful.</mso:HtmlDesignStatusAndPreview>
- </mso:CustomDocumentProperties>
- </xml><![endif]-->
- </head>
- <body>
- <script>
- $includeCSS(this.url, "~sitecollection/Style%20Library/Menu/bootstrap.min.css");
- $includeScript(this.url, "~sitecollection/Style%20Library/Menu/bootstrap.min.js");
- $includeScript(this.url, "~sitecollection/Style%20Library/Menu/jquery.min.js");
- </script>
- <div>
- <!--#_if (!$isNull(ctx.ClientControl) && !$isNull(ctx.ClientControl.shouldRenderControl) && !ctx.ClientControl.shouldRenderControl()){return "";}
- ctx.ListDataJSONGroupsKey = "ResultTables";
- ctx["CurrentItems"] = ctx.ListData.ResultTables[0].ResultRows;
- var siteURL = SP.PageContextInfo.get_siteAbsoluteUrl();
- AddPostRenderCallback(ctx, function() {
- $.getScript(siteURL + "");
- });
- _#-->
- <nav class="navbar navbar-inverse">
- <div class="container-fluid">
- <div class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a> </div>
- <ul class="nav navbar-nav"> _#= ctx.RenderItems(ctx) =#_ </ul>
- </div>
- </nav>
- </div>
- </body>
- </html>









Ravi KandelPosted Mar 8, 2017, 8:35 AM
Awesome Thanks for sharing
Vinodh NarayananPosted Feb 6, 2017, 5:07 AM
Joe Wilson Thanks mr wilson will share more like this soon
Joe WilsonPosted Jan 20, 2017, 4:43 AM
Well, thank you for sharing.