How can I always show the left sidebar on some pages when using the Documentation theme?

I need some of the pages to always show the left navigation in the documentation theme.

I am thinking of something somewhat opposite to that hiding it. So far, once you hid it on one space, it seems to remember that - so when users navigate from there - the left navigation is still hidden.

We want the left navigation to always remain. Is there a way to completely show this on the page.

Thanks,

2 answers

1 accepted

2 votes
Accepted answer
Davin Studer Community Champion Sep 25, 2013
Davin Studer Community Champion Sep 25, 2013

You could put this into an HTML macro in the page.

<script type="text/javascript">
AJS.toInit(function () {
	var splitPos = AJS.$('#splitter .vsplitbar').css('left')
	if(splitPos === '0px') {
		AJS.$('#splitter-button').click();
	}
});
</script>

Hi David,

Can you please explain further how this code helps?

<script type="text/javascript">
AJS.toInit(function () {
    var show = getParameterByName('show_sidebar');
    var splitPos = AJS.$('#splitter .vsplitbar').css('left')
    if((show === '1' && splitPos === '0px') || (show === '0' && splitPos != '0px')) {
        AJS.$('#splitter-button').click();
    }
});
 
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
    results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
</script>

I already added it but it doesnt seem to work. When i navigate from a hidden left navigation page to another space - the left navigation is still hidden,

it works! Thank you so much! :)

Davin Studer Community Champion Sep 25, 2013

Check out my code above. I adapted it from the link I sent in the answer. In the original link I sent the user was looking to control the nav based on a parameter passed in the url. The code above is adapted from that. If you put it into a page then it will always be open when you go to that page. You could even adapt this further to be a user macro (less easy to mess up and easier to add on multiple pages). He is an example. This would allow you to just put a macro called opennav on any page you want the nav open on.

Macro Name:
opennav

Macro Ttle:
Open Nav

Description:
Open the nav on page access.

Macro Body Processing:
No macro body

Template:
## Macro title: Open Nav
## Macro has a body: N
## Developed by: Davin Studer
## Date created: 09/26/2013
## Open the nav on page access.

## @noparams

<ac:macro ac:name="html">
<ac:plain-text-body><![CDATA[<script type="text/javascript">
AJS.toInit(function () {
var splitPos = AJS.$('#splitter .vsplitbar').css('left')
if(splitPos === '0px') {
AJS.$('#splitter-button').click();
}
});
</script>]]></ac:plain-text-body>
</ac:macro>

It's simple as it is:

Macro Name:
collapsesidebar

Macro Title:
Collapse Sidebar

Description:
Collapse sidebar by default (everywhere!)

Macro Body Processing:
No macro body

Template:
## Macro title: Collapse Sidebar
## Macro has a body: N
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Barbara Boros
## Date created: 08/28/2014
## Installed by: Barbara Boros

## @noparams

&lt;style&gt;
    #main {
        margin-left: 55px !important;
    }
&lt;/style&gt;

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 24, 2018 in Confluence

Atlassian Research opportunity with Confluence templates

Do you use templates with Confluence? Take part in a remote 1-hr workshop. You'll receive USD $100 for your time!   We're looking for people to participate in a   remote 1-hr workshop...

1,181 views 20 14
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you