Hi,
is there a way to collapse the sidebar by default. We're using the Default Theme.
Community moderators have prevented the ability to post new answers.
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).
Hello!
Looks like it's work only in Google Chrome.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I use latest 5.10.4, may be it's a reason, but in any case - thank you a lot!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 < looks like < and > looks like >
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nice - I'm glad soemone know what they are doing - thanks very much
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jum
You can refer on this: https://answers.atlassian.com/questions/3308/how-can-i-hide-the-left-sidebar-on-some-pages-when-using-the-documentation-theme
Hopefully it helps!
Cheers :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jum
Yes you can.
Here you go: https://confluence.atlassian.com/pages/viewpage.action?pageId=330796984
Hopefully it helps!
Cheers :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When I click on the link Daryl, I get an error: No Permission
Page level restrictions have been applied that limit access to this page.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.