Compact sidebar per default
Asked by Bj?rn Eitmann:

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

![](https://confluence.atlassian.com/download/attachments/302809812/NewSidebarCollapsed.png?version=2&modificationDate=1361406020012&api=v2&effects=border-simple,blur-border)


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


author: Bj?rn Eitmann
body: 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!

comments: author: Davin Studer
body: What do you mean by click on "pages"?


author: Bj?rn Eitmann
body: 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.


author: Davin Studer
body: 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?


author: Bj?rn Eitmann
body: 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.


author: Bj?rn Eitmann
body: 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!


author: Davin Studer
body: 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.


author: Davin Studer
body: 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.

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

comments: author: Davin Studer
body: 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\>


author: Davin Studer
body: 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>
```


author: Shawn Smith
body: 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.


author: Davin Studer
body: 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.


Tags: confluence-administration