How to hide tabs?

I found where to either show or hide the tabs on pages globally.
Is there a way to show or hide them based on user or group?

You probably want to customize some default templates, see:

It’s not an easy change and could easily break your wiki. Make sure to test them properly before applying them to your existing wiki :slight_smile:


If you don’t have access to the template files, I doubt it’s possible to do this. Maybe you can inject your own logic to update $showcomments (and other similar variables) values in between the place where they are defined (xwikivars.vm) and the place they are consumed (docextra.vm)… Not sure of how stable and reliable it’d be though.


Have a good day!
Lucas C.

PS: I assumed you were talking about the docExtraTabs that display metadata about pages on the bottom of the default view mode.

I was talking about these:

That’s what I assumed :+1:
The explanation I provided should be relevant to help you :slight_smile:

That is definitely beyond my skill level.
What’s the site where you can propose new feature in xwiki?
It seems like it would be smart to be able to hide/show those tabs based on role.

Some Jira issues already exists on this topics:

But, feel free to open an issue for your specific usecase.

1 Like

You can do this by writing a XWiki.StyleSheetExtension (object editor) which hide page elements (e.g. identified by their ID) by adding css style attributes.

The CSS code of the Extension is something like:

#if($xwiki.user.getUser()=="XWiki.TargetUserName")
#Commentstab,#Commentspane{display:none}
#Attachmentstab,#Attachmentspane{display:none}
#Historytab,#Historypane{display:none}
#Informationtab,#Informationpane{display:none}
#end

#if($xwiki.user.isUserInGroup("XWiki.XWikiAdminGroup"))
h1,h2,h3,h4,h5,h6 {color:red}
#end

(The second part is just of proof of concept, which change the headline colors for admin users)

Important:

Sone attributes of the StyleSheetExtension need special values:

Parse Content must be set to true
Caching policy must be set to forbid
Use this extension must be set to always

Note:

  • This style be loaded additionally on every wiki page - this gives more overhead

  • Security: The content of the tabs is still present in the browser. It is only hidden. With browser development tools (F12) a user may change the display css attribute and will get the suppressed information.

  • The used ids of the wiki page elements may be changed by different wiki version.