Roman S.
Roman S.

Reputation: 1216

Hide sidebar on a page in Confluence 5.1

I'm using Confluence 5.1 and I'd like to hide the sidebar - but only on a few pages. I only found a JQuery based solution which does not seem to work right in all browsers. It seems to hide the sidebar completely regardless of the default settings.

Upvotes: 2

Views: 1783

Answers (2)

Adam Katz
Adam Katz

Reputation: 16138

There was a Confluence bug filed for this and it was rejected* due to a desire to have a more simplified configuration system. In that bug, a workaround is proposed.

Add this to a <script> stanza at the bottom of the <head> tag in your custom HTML:

AJS.toInit(function(){
  if (AJS.$("div.ia-fixed-sidebar").width() > 55){
    AJS.Confluence.Sidebar.toggle();
  }
});

Since I don't have that level of control, I opted for a Greasemonkey script instead. This only affects me, but it does solve my problem (I just have to make sure I don't take too much advantage of the extra width this affords me). Here is a sample userscript for this, also posted to Github [install]

// ==UserScript==
// @name        Confluence - Hide sidebar
// @namespace   https://github.com/adamhotep
// @description Collapse the sidebar upon page load
// @include     https://confluence.*
// @include     http://confluence.*
// @version     1
// @grant       none
// @license     GPL
// ==/UserScript==

// from https://confluence.atlassian.com/confkb/how-do-i-remove-the-side-bar-in-confluence-5-330796984.html
if (typeof AJS === 'function') {
  AJS.toInit(function(){
    if (AJS.$("div.ia-fixed-sidebar").width() > 55){
      AJS.Confluence.Sidebar.toggle();
    }
  });
}

This is theme-specific. The above code assumes the default theme and is not guaranteed to work in later versions of Confluence. See the "workaround" link for the code needed for the documentation theme.

 

* There's also another bug related to a cookie that is supposed to preserve whether or not to show or hide the sidebar. Supposedly, the bug is fixed, but this directly contradicts the first bug linked in this answer, so I can't make sense of it.

Upvotes: 2

bischoffdev
bischoffdev

Reputation: 175

I found a CSS based solution for this after searching around the web for a long time.

Basically, all you need to do is add a CSS macro to the page which shouldn't have a sidebar containing the code below.

CSS Stylesheet macro

#splitter-content {
    width: 100% !important;
    left: 0px !important;
}

.vsplitbar{
    visibility: hidden;
}

This CSS block spans the page content over the whole page width and removes the left margin normally reserved for the sidebar. It also hides the split bar which is normally used to change the sidebar size.

The nice thing is that you don't have to mess with cookies this way or make sure the sidebar is turned back on on the following pages.

Upvotes: 3

Related Questions