Compact sidebar per default

Hi*

We want our HOME pages to view the compact sidebar per default. At the moment we first have to click on pages to view this. This is one click to much ;-)

Some ideas to do that?

Best,

Björn

3 answers

0 votes
Davin Studer Community Champion Sep 25, 2013

You could put this into an html macro on your home page. It will check if the sidebar is collapsed. If not it will programatically click the collapse handle for you.

<script type="text/javascript">
AJS.toInit(function () {
	if(AJS.$('.ia-fixed-sidebar.collapsed').length == 0) {
		AJS.$('.ia-fixed-sidebar .space-tools-section .expand-collapse-trigger').click();
	}
});
</script>

Davin Studer Community Champion Sep 25, 2013

You could even take it a step futher and create a user macro that you could put on any page that you want to have the nav collapsed by default.

Macro Name:
collapsenav

Macro Ttle:
Collapse Nav

Description:
Collapse the nav on page access.

Macro Body Processing:
No macro body

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

## @noparams

<ac:macro ac:name="html">
<ac:plain-text-body><![CDATA[<script type="text/javascript">
AJS.toInit(function () {
if(AJS.$('.ia-fixed-sidebar.collapsed').length == 0) {
AJS.$('.ia-fixed-sidebar .space-tools-section .expand-collapse-trigger').click();
}
});
</script>]]></ac:plain-text-body>
</ac:macro>

Davin Studer Community Champion Sep 29, 2013

Ok, I think this should meet your needs to have the fly-out navigation appear by default.

Macro Name:
collapsenav

Macro Ttle:
Collapse Nav

Description:
Collapse the sidebar and show fly-out nav on page access.

Macro Body Processing:
No macro body

Template:

## Macro title: Collapse Nav
## Macro has a body: N
## Developed by: Davin Studer
## Date created: 09/26/2013
## Collapse the sidebar and show fly-out nav on page access.

## @noparams

<ac:macro ac:name="html">
	<ac:plain-text-body><![CDATA[<script type="text/javascript">
	AJS.toInit(function () {
		if(AJS.$('.ia-fixed-sidebar.collapsed').length == 0) {
			AJS.$('.ia-fixed-sidebar .space-tools-section .expand-collapse-trigger').click();
		}
		AJS.$('.ia-secondary-header .parent.ia-secondary-header-title.wiki .parent-item .parent-item-link[title=Pages]').click();
	});
	</script>]]></ac:plain-text-body>
</ac:macro>

Davin,

When setting this up in Confluence 5.3.1, it works, but once collapsed it seems like all Global Theme spaces and other pages in the same space are now collapsed as well.

Davin Studer Community Champion Nov 19, 2013

Yeah, it programatically clicks the collapse button which saves the state. If you want to only collapse it on certain pages, you would have to set the css styles manually so that it is not carried to other pages.

Thank you very much! One problem left ...

We have to choose the default theme, because we are using the design plugin CUTE. Is it possible to script that macro to click first on "pages" so that we can use the default theme and have the compact sidebar?!

That would be great!

Davin Studer Community Champion Sep 26, 2013

What do you mean by click on "pages"?

When using the default theme the homepages of the spaces are without sidebar. So if we want to see them, we have to click on the link pages above the space title to have a sidebar. would be fine, if we could use the default theme WITH a compact sidebar per default on the space home's.

Davin Studer Community Champion Sep 29, 2013

Ok, I think I get what you are saying. Are you wanting to have the fly-out navigation visible by default on the home page?

Hi Davin. No, we have a special designed Space for our company homepage, so i have to use the macro on the spaces wich should show the compact sidebar on their home's.

Hi Davin

I am sorry, but that is not what we need. We just want to have the default compact (small) sidebar on a few pages without clicking on "pages" first. That would be great. The Navigation out of the macro you build hides our company logo.

Thanks a lot for your help!

Davin Studer Community Champion Oct 01, 2013

Ok. I removed the second answer. The first user macro should get you what you want. It should compact the sidebar by default on any page that the macro is included on.

0 votes
Brian Tom Atlassian Team Sep 26, 2013

Hi Bjorn, one other thing to be aware of is that the sidebar width preference is stored in a cookie.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in New to Confluence

How to use Confluence Cloud for stakeholder management

Most of us don’t need much convincing that stakeholder management is important. It just makes sense that keeping everyone in-the-know on projects and assigning clearly defined roles is key to having ...

1,104 views 1 6
Read article

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