Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Collapse Sidebar by default - Default Theme

Jum May 5, 2013

Hi,

is there a way to collapse the sidebar by default. We're using the Default Theme.

5 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 6, 2016

This is an old thread, but I may have a simple solution to contribute.

I needed something similar... the home page of a space is generally more carefully curated.
We wanted that homepage to have a nice layout and force the sidebar to be collapsed to allow as much real estate as possible regardless of what the user wants or has done before.

Other pages in the space, we don't care so much. We're happy for the default behavior and user preferences to take effect.

So I created a quick user macro that, when dropped on a page, causes the sidebar to collapse (but remain visible) every time the page is loaded or reloaded. 

## @noparams
<script type="text/javascript" >
   jQuery(document).ready(function() {
      if(jQuery('.ia-fixed-sidebar.collapsed').length == 0) {
         jQuery('.expand-collapse-trigger').click();
     };
   });
</script>

I suppose you could add that to the theme somewhere to have it work globally (inside html macro).

Alexander
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 7, 2016

Hello!

Looks like it's work only in Google Chrome.

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2016

I have no issue with the above in firefox, ie11 and chrome. 

But, with our current version of confluence (5.9.9) this poses a problem because of the sidebar state is remembered for users from page to page.

And when visiting a page with the macro above, the user's preference is set,

So instead, I've started hiding the sidebar on certain page using a macro:

## @noparams
<script type="text/javascript" >
   jQuery(document).ready(function() {
      jQuery('.ia-fixed-sidebar').hide()
      jQuery('.aui-page-panel').css('margin-left','0px')
   });
</script>

Note that this will prevent space admins from accessing the space tools from this page since the space tools icon will also be hidden.

I also have no issues with this in chrome, firefox or ie11.

Alexander
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 7, 2016

I use latest 5.10.4, may be it's a reason, but in any case - thank you a lot!

Chris Swinney July 6, 2017

Hi Peter,

I have literally just started using Confluence (6.2) and the sidebar needs to be one of the first things to be modified. I can’t quite believe there is no option to do this OOTB, but after finding this, I thought that this is exactly what I was after, however I could not get this to work at all. I have tried adding the User Macro as originally posted (with all 4 option, just in case), and just dropping it on the home page of a space, but nothing happens. I assume I’m doing something wrong as newbie.

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 6, 2017

This site at some point started to not display code correctly apparently.

Make sure in your macro that you decode all the html encoding so the &lt; looks like < and &gt; looks like >

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 6, 2017

Trying to see if I can re-insert the code and not get encoded

## @noparams

<script type="text/javascript" >
   jQuery(document).ready(function() {
      if(jQuery('.ia-fixed-sidebar.collapsed').length == 0) {
         jQuery('.expand-collapse-trigger').click();
     };
   });
</script>

 

Chris Swinney July 6, 2017

 Great thank Peter. That works great for Chrome, but like Alexander above, Firefox (54 on PC) doesn’t seem to work. Can’t try IE or Edge as they are broken in later Windows builds and cannot browse through an IPsec VPN tunnel. 

 
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 6, 2017

I've just tried in Firefox and saw that it didn't work too... appears to be a timing of when the script is triggered (i.e. the navigation bar doesn't yet exist when the macro is rendered and runs).

The following works in Firefox:

## @noparams

<script type="text/javascript" >
jQuery(document).ajaxComplete(function() { if(jQuery('.ia-fixed-sidebar.collapsed').length == 0 ) { jQuery('.expand-collapse-trigger').click();
}; }); </script>

This runs when all ajax calls are complete rather than as soon as the base document is loaded. 

Edited to add:

But it has the problem that is executes multiple times while the page is open (every time confluence makes a call to refresh content). So if the user attemps to expand the navigation, it will collapse it again almost immediately.

You would need to expand on that logic perhaps to prevent this.

Maybe something like:

## @noparams

<script type="text/javascript" >
   var runOnce = false;
   jQuery(document).ajaxComplete(function() {
      if(jQuery('.ia-fixed-sidebar.collapsed').length == 0 && runOnce == false) {
         jQuery('.expand-collapse-trigger').click();
         runOnce = true
     };
   });
</script>
Chris Swinney July 6, 2017

Nice - I'm glad soemone know what they are doing - thanks very much

1 vote
Daniel Borcherding
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2013

Hello Jum,

I filed a feature request a while ago to have Confluence remember when you had collapsed this sidebar.

https://jira.atlassian.com/browse/CONF-29409

Your requested behavior sounds like another feature request that would relate to this one. Perhaps we could set a java arg to collapse this sidebar by default. Then if confluence is smart enough to remember individual preferences the sidebar can be expanded on a per user basis.

I am happy to file this request on your behalf.

Jum June 2, 2013

Hi Daniel,

it'd be great if you could file the request on my behalf.

Cheers

0 votes
darylchuah
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 5, 2013
Jum May 5, 2013

Sry, but I can't get it to work.

Jum May 6, 2013

The only thing I manage doing is hiding the sidebar. Is there anyone who knows how to collapse the sidebar?

0 votes
Jum May 5, 2013

Hi Daryl,

thanks for the answer. However, if I remove the code the sidebar is completely gone. I only want the sidebar to be collapsed by default instead of being expanded.

0 votes
darylchuah
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 5, 2013

Hi Jum

Yes you can.

Here you go: https://confluence.atlassian.com/pages/viewpage.action?pageId=330796984

Hopefully it helps!

Cheers :)

Jum May 5, 2013

Hi Daryl,

thanks for the answer. However, if I remove the code the sidebar is completely gone. I only want the sidebar to be collapsed by default instead of being expanded.

SUNYITECVal May 28, 2013

When I click on the link Daryl, I get an error: No Permission

You cannot view this page

Page level restrictions have been applied that limit access to this page.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events