This documentation has moved. For the most recent documentation, check out https://docs.adaptavist.com. Please update your bookmarks and links.

Skip to end of metadata
Go to start of metadata

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 will be setting 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. In ThemeBuilder Panel Editor, select the skin you want to work with and click to edit the flagLogic panel.
  2. Scroll down to the end and use ‘Insert Macro’ to select the ‘builder-show' macro.
  3. In the options, scroll down to ‘Group Membership ‘ and add ‘confluence-users . Click 'Save'.
  4. Then click between the <ac:rich-text-body> tags, create a space, and use ‘Insert Macro’ to select the ‘set-flag’ macro.
  5. In the options here:
    give the flag a useful memorable name (example shows ‘conf-user’)
    set the ‘State’ to ‘true’
    set the ‘Type’ to ‘user’
  6. Click 'Save' and then 'Apply'.
  7. Repeat 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>

So you have 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 ‘confluence-administrator’

If a Confluence user or administrator browses to 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 that 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 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 in 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 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 the Likes and Labels from administrators

The Likes and Labels content is added in the ‘content’ panel by the 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. An Administrator sees

 

 

  • No labels