Hide some content of a page in editing view ?
Asked by Paul LALANNE:

Hi (an sorry for my english),

Would there be a way to hide some content of a page, but only in edit view? So that defined users could be able to see the entire content of the page in normal view, but not be able to edit the concerned parts?

I've tried the visibility plugin but with no result (i'm able to hide some content in normal view, but not in edit...). I'm not even sure that there's a way to achieve this.

I'm trying to make the edit view the most "simple" as possible, because the page layout (ex: sections and colums macros, etc) could confuse some of my users. I think i can't do this with template variables, due to the amount of text the users should be able to add.

Any help would be apprecated...

Thanx in advance.


Answers:
author: Fabian Hu?l
body: Hi,

I liked the idea of [@Stephen Deutsch2](/t5/user/viewprofilepage/user-id/853444) and wrote a User Macro.

```
## Macro title: Hidden Metadata 
## Macro has a body: Y 
## Body processing: Rendered 
## 
## Developed by: Fabian Hu?l 
## Date created: 27/06/2019 
## Installed by: My Name 

## @noparams 

<div>$body</div>?
```

The actual magic happens in **Custom HTML** via Javascript at *At end of the BODY*.

```
<script type="text/javascript"> 
? AJS.toInit(function ($) { 
? ? setTimeout(function () { 
? ? ? if ( !AJS.Meta.get('is-space-admin') || jQuery('#space-admin-link').length == 0 ) { 
? ? ? ? jQuery("#wysiwygTextarea_ifr").contents().find("table.wysiwyg-macro[data-macro-name='hidden-metadata']>tbody>tr>td.wysiwyg-macro-body").attr("style", "display:none;"); 
? ? ? } else { 
? ? ? ? jQuery("#wysiwygTextarea_ifr").contents().find("table.wysiwyg-macro[data-macro-name='hidden-metadata']>tbody>tr>td.wysiwyg-macro-body").attr("style", "display:table-cell;"); 
? ? ? } 
? ? }, 2000); 
? }); 
</script>
```

The user macro should make it possible to hide content in the edit mode of a page for non-administrators.

Administrators see all content as usual.

Regards  
Fabian


author: Paul LALANNE
body: I tried this this morning, with the include page macro. It worked, but not rendered properly some parts of the layout. I'll give a try to the excerpt one. Hoped a "hide" macro would have done the job better.

Thanx a lot anyway.

Regards.


author: Guilherme Nedel [Atlassian]
body: Hello Paul, there is one way to enclose content in a separate macro which can keep customers away from editing such, the only risk would be to have the macro itself removed from the page:

There is a Macro called [Excerpt Include](https://confluence.atlassian.com/display/DOC/Excerpt+Include+Macro) which can pull content from another page into the target one, and one can assign edit permissions to the originating page.

Hope this can be a solution.


author: Paul LALANNE
body: Hi Stephen.

Thanks a lot for your answer and the tip. I'll give it a try.

Thanx again.


author: Stephen Deutsch
body: Hi Paul,

There's not really such a good way to do so, but you might consider copying and pasting the content (using the source editor plugin) into a user macro (and setting it to visible only for administrators). That's the only way I know of that you could do what you asked. Just be aware that if you have to do this for a lot of pages you will have a ton of user macros... Not exactly ideal, but there you have it.

Best regards

Stephen


Tags: confluence-administration

custom-field

edit