Friday, June 13, 2014

Enabling Quick launch menu based on Site Template ID

Introduction

I am going to share my thoughts about enable the quick launch for particular site template.

Master Page Customization

First, we needs to check the .sideNavBox class in master page. This class only enabling the quick launch (left) in all the pages. On my case i need to enable the left navigation for Community sites only. So i have disabled the .sideNavBox using style.

.sideNavBox{display:none;}

Now, we are going to enable the .sideNavBox using jquery

Java Script to enable left navigation

In SharePoint, we have a var called g_wsaSiteTemplateId to find the site template. I have take that variable to check site template and enable the sideNavBox. Here the jquery script to enable the menu.

<script type="text/javascript">
    $(document).ready(function () {
        if (g_wsaSiteTemplateId == 'COMMUNITY#0') {
            document.getElementById('sideNavBox').style.display = 'block';
        }
    });
</script>

Do this script in your master page. Then, Left navigation will come based on the site template.

Happy Coding..... !!!!!!

No comments:

Post a Comment