Hide a macro for a specific page that's been added in the space layout
Asked by Alexander Yolov:

If I add a macro through the space layout, so that all pages within the space have it, is there a way to specify only some pages that won't have it? I imagine it would be easier to add the macro 'globally' in this way and only manually hide it for some pages, instead of adding it to all pages.

So far, I've used HideElements and the css selector, but I was wondering if there's another way?

Thanks in advance,

Alex


Answers:
author: Diego
body: Hello Alexander!  
Well, you are right. Usually this should be done with CSS customization. I understand you already have a solution for that, but here is our documentation:  

- **[How to hide elements in Confluence using CSS or JavaScript](https://confluence.atlassian.com/confkb/how-to-hide-elements-in-confluence-using-css-or-javascript-313458894.html)**   

Also, would you be able to share with us your custom solution for this situation? This could aid other customers with the same situation!  
Now, looking at our Marketplace I have found this plugin:  

- **[Visibility for Confluence](https://marketplace.atlassian.com/apps/202/visibility-for-confluence?hosting=server&tab=overview)**   

This plugin could help you to achieve the desired results.   
Let us know if you solve this!

comments: author: Alexander Yolov
body: Hey and thanks for the answer.

My current solution is in my first post - I've added a macro to all pages in a space 'globally' by adding it to the page header/body/footer (as needed) using the 'space layout' control - this practically adds it to every page's header (for example) in a space. Then on specific pages where I don't want the macro to show - I'm using the 'hide elements' macro to specify a css selector: [https://marketplace.atlassian.com/apps/1211757/hideelements-for-confluence?hosting=server\&tab=overview](https://marketplace.atlassian.com/apps/1211757/hideelements-for-confluence?hosting=server&tab=overview) - this saves me a lot of time as I'm adding something 'globally', then 'hiding' it from the handful of pages where it's not needed.

As for 'visibility to confluence' - it didn't seem like the most suitable thing for me, as I don't want to restrict access to user(s)/group(s), but for all and any users and groups at the same time.

The specific task I'm doing is - I wrote a custom floating page contents menu to replace my old static table-of-contents and I did it as a user macro. The easiest way to add it to new spaces 'globally' (i.e. to all pages in a space, even newly created ones) seemed to be adding the macro to the page header via the space layout. Then I have the home page where I don't want any menus whatsoever - so I'm just adding a 'hide elements' macro manually to the home page and specifying the css selector for my custom user macro and that's it.

Alex


author: Alexander Yolov
body: I was just wondering if anyone knows of a 'better' way that's considered 'good practice'.

Alex

P.S. if you think it's going to be useful - I can add some steps and screenshots to describe my workflow.


author: Diego
body: Hello Alexander!

Since it is a customization, there is not a strictly better way of doing. There are other ways of course, such as the macro.

You just need to be careful and check if the code you created does not affect other parts of Confluence usage.

If you can share your steps and screenshots for this procedure, you would surely help others in similar situations!


Tags: confluence-server

server