For ThemeBuilder version 5.5.0+ / Confluence 5.9.7+, the flagLogic method has been changed. Please see the main panel for the logic that controls which sidebar panel to show.

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 basic users from those with higher permissions.

  1. Click the Confluence Administration icon, and select General Configuration.

  2. Choose Edit Skins from the ThemeBuilder section of the left sidebar.

  3. Select the skin you want to edit, and click the Panels tab.

  4. Click the flagLogic Edit Panel Content icon to edit the panel contents.

  5. Scroll down to the end, and click Insert Macro, then select the Builder Show macro. In Options, scroll down to the Group Membership text field, and add confluence-users. Click Insert.

  6. Click between the <ac:rich-text-body> tags, create a space, and click Insert Macro, then select the Set Flag macro.

  7. Set the following options for the macro:

    • Give the flag a useful, memorable name (conf-user).

    • Set the State to True.

    • Set the Type to User.

  8. Click Insert, then click Apply to save all changes.

  9. Repeat steps 5 through 8 for the confluence-administrators group.

<ac:macro ac:name="panel-show">
<ac:parameter ac:name="group">confluence-users</ac:parameter>
<ac:rich-text-body>
<ac:macro ac:name="set-flag">
<ac:parameter ac:name="name">conf-user</ac:parameter>
<ac:parameter ac:name="state">true</ac:parameter>
<ac:parameter ac:name="type">user</ac:parameter>
</ac:macro>
</ac:rich-text-body>
</ac:macro>
<ac:macro ac:name="panel-show">
<ac:parameterac:name="group">confluence-administrators</ac:parameter>
<ac:rich-text-body>
<ac:macro ac:name="set-flag">
<ac:parameter ac:name="name">conf-admin</ac:parameter>
<ac:parameter ac:name="state">true</ac:parameter>
<ac:parameter ac:name="type">user</ac:parameter>
</ac:macro>
</ac:rich-text-body>
</ac:macro>

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 has been 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 and Macros

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 right 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;
 }

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, and this 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.