I wanted to write this article for a very long time. Here, I am writing to the fellow developers who want to play around with SharePoint branding by customizing it based on their requirements.
Basically, all the customizations start with Master Page as far as the SharePoint On-premises is concerned.
Here are a few simple steps to be followed for achieving the customized global navigation cum branding in SharePoint 2013.
Step 1
- In the SharePoint site, go to Site Settings > Master pages and page layouts.
- Select Library > Open with Explorer.
- Make a copy of “seattle.html” in your local and edit the name of the file. Let’s say MyMaster.html and upload it back to the Master page document library.
- It’ll create another file with the extension “.master” with the same name “MyMaster.master”.
- We won’t be able to edit the “MyMaster.master” directly and we do all the changes in the “MyMaster.html” file only.
Step 2
- Now, open the “MyMaster.html” file in an editor of your choice and do the below changes.
- Add the jQuery reference under the <Head> tag.
- <script type="text/javascript" src="jquery-1.12.4.js">
- </script>
- Add the below scripts next to the above code.
- <script type="text/javascript">
- $(document).ready(function() {
-
- $('.ms-core-brandingText').replaceWith('<div><a href="#"><img src="Image.png " alt=”" title="Title"/></a></div>');
-
- var div = document.createElement('div');
- div.setAttribute('class', 'GlobalNav');
- div.innerHTML = document.getElementById('divGlobalNav').innerHTML;
-
- $('#DeltaSuiteLinks').replaceWith(div);
-
- $('.CH-userInfo').on({
- mouseenter: function() {
- $('.CH-userInfoPopup').show();
- },
- mouseleave: function() {
- $('.CH-userInfoPopup').hide();
- }
- });
- $('nav li').on({
- mouseenter: function() {
- $('.CH-subMenu').each(function() {
- var colCount = $(this).find('.CH-subMenu-col').length;
- $(this).width(320 * colCount - 50);
- });
- $subMenuDiv = $(this).find('.CH-subMenu');
- if ($subMenuDiv.length) {
- nw = $('nav').width();
- sw = $subMenuDiv.width();
- $subMenuDiv.show();
- menuTotalW = $subMenuDiv.offset().left + $subMenuDiv.width();
- ew = (menuTotalW - $subMenuDiv.width()) / 2;
- if (menuTotalW > 1280) {
- if (nw > sw) {
- sw = nw - sw;
- } else {
- sw = 0;
- }
- $subMenuDiv.offset({
- left: ($('nav').offset().left) + sw
- })
- }
- }
- },
- mouseleave: function() {
- $(this).find('.CH-subMenu').hide();
- }
- });
- });
- </script>
- <!--Here is the global navigation div elements which can be customized as per the your needs-->
- <div id="divGlobalNav" style="display:none;"> <span id="navbar">
-
- <!--
- <header class="">
- <div class="CH-innerContainer">
- <nav class="">
- <ul>
- <li><a href="javascript:void(0);" class="">myApps</a>
- <!-- Submenu-->
- <div class="CH-subMenu" style="overflow-y:scroll;height:500px">
- <div class="CH-subMenu-col">
- <div class="CH-subMenu-Item app-all" style="display: block;">
- <h3 class="icon-myPage">
- <a href="#/">myPage</a>
- </h3>
- <div class="CH-subMenu-Desc">Description</div>
- <div class="CH-readMoreNav">
- <a href="#">[+] Go to</a>
- </div>
- </div>
- </div>
- </div>
- </li>
- <li><a href="javascript:void(0);">myPortals</a>
- <!-- Submenu PORTAL TOOLS -->
- <div class="CH-subMenu" style="width: 910px; display: none;">
- <div class="CH-subMenu-col">
- <div class="CH-subMenu-Item app-permanent" style="display: block;">
- <h3 class="no-icon">
- <a href="#" target="_blank">
- <img src="#" alt="">
- </a>
- <span class="icon-lock" title="Requires additional Login"> </span> <span class="icon-new-window" title="External Site"></span> </h3>
- <div class="CH-subMenu-Desc">Description</div>
- <div class="CH-readMoreNav"> <a href="#" target="_blank">[+] Go to</a> </div>
- </div>
- </div>
- </div>
- </li>
- </ul>
- </nav>
- </div>
- </header>
- <!--
- </span>
- </div>
Step 3
- Save the MyMaster.html file and upload it under the Master Pages library.
- Check in the MyMaster.Master Page and publish a Major Version.
- All set now! The testing phase and bug fixing starts from here!!
Output
I hope it will help a wide range of developers!!
Happy SharePointing!!