Using Flags to Control Content Display
Setting Logic Flags by User Group
This example sets a flag (conditional value) whenever the page viewer is a member of the confluence-users or confluence-administrators group. This will separate primary users from those with higher permissions.
You have now told ThemeBuilder to set a value of conf-user into its logic whenever the user is in the group confluence-users and conf-admin when a user is a confluence-administrator. If a Confluence user or administrator browses a page that uses this skin and views the HTML source, they can see a CSS class added to the <body> tag for each group they are a member of (e.g., flag-conf-user'). Any flag you set will appear in the body tag in this way.
Using Logic Flags with CSS
You can use this flag to selectively change the CSS for all users by the group they belong to. By ensuring the most important group always appears last in the flagLogic macros and the relevant CSS, the logic hierarchy will always follow the correct order of permissions—least permissions to all permissions.
Using Firebug in Firefox, or other similar developer tools, you can find the CSS class or ID needed to target any Confluence page item. The class for the sidebar Space Tools link is: acs-nav-item settings. Combining this with the flag-conf-user class now showing in the body tag, you can build CSS that will hide the Space Tools link for confluence-users. Then you make it visible again for confluence-administrators.
For neatness, this CSS also hides or shows the <hr> that divides the navigation for this section.
.flag-conf-user .acs-nav-item.settings,
.flag-conf-user .acs-nav-wrapper hr {
display: none;
}
.flag-conf-admin .acs-nav-item.settings,
.flag-conf-admin .acs-nav-wrapper hr {
display: block;
}Using Logic Flags with Macros
Now that you have a flag set for Confluence users or administrators, you can use this in ThemeBuilder macros to display or hide content. All ThemeBuilder macros can detect and use a flag, which means less use of the Show or Hide macros.
Example: Hiding Likes and Labels from Administrators
The Likes and Labels content is added in the content panel by using the following code:
<ac:macro ac:name="panel-element">
<ac:parameter ac:name="element">page.labels-editor</ac:parameter>
</ac:macro>
To change its visibility, click on the code, click Edit Macro, and add the flag we added earlier, conf-admin, to the Not Flag field. This means that if the flag conf-admin is set, ThemeBuilder will not display the Likes and Labels content.