Martin
Martin

Reputation: 33

Show left nav only on admin pages

In SharePoint 2010, I want the left navigation to show up only on admin pages i.e. pages like _layouts/settings.aspx etc.

I created a solution based on JavaScript function which is run as a jQuery document ready.

In my custom .css file, I made these changes to hide the left panel on pages:

body #s4-leftpanel
{
    display: none;
}

.s4-ca
{
    margin-left: 0px;
}

This function will show the left panel on pages that have either _layouts or _catalogs in the path:

function ShowLeftNav() {
    if ((location.pathname.indexOf('_layouts') != -1) ||
        (location.pathname.indexOf('_catalogs') != -1))
     {
        $('#s4-leftpanel').show();
        $('.s4-ca').css('margin-left', '155px');
     }
}

I wonder if there is a more elegant solution, especially to recognize that an admin page is currently loaded.

Upvotes: 1

Views: 936

Answers (1)

Mark Mascolino
Mark Mascolino

Reputation: 2292

is this a publishing site? SharePoint does give those sites two different master page options. One is for traditional end user pages and the other is for SharePoint system pages. You could obviously add your CSS hiding styles only in the master page meant for end users.

Upvotes: 1

Related Questions