ThemeBuilder for Confluence Server and DC

Panel Hide

This macro is used for showing/hiding content based on the context at the theme level.

Usage

Storage Format

<ac:macro ac:name="panel-hide">
<ac:parameter ac:name="parameter">value</ac:parameter>
<ac:rich-text-body>
<!-- content to show here -->
</ac:rich-text-body>
</ac:macro>

Wiki Markup

{panel-hide:parameter=value}
<!-- content to show here -->
{panel-hide}
When nesting panel-hide you do not need to number the macros as had to be done in builder-hide.
Parameter Name Description Type Default Required

mode

Mode

Only hide the content for specific modes, eg. "view", "edit", etc.

string

error

context

Context

Only hide the content for specific context(s), eg. "page", "global", etc.

string

error

decorator

Decorator

Only hide the content when a specific decorator us being used, eg. "printable", etc.

string

error

action

Action

Only hide the content for specific action(s), eg. "viewpage". NB: The ".action" part of the action name should not be included.

string

error

label

Page has Label

Only hide the content if the the current location (page, news, etc) has the specified label(s), eg. "my:favourite", "meetings", etc.

string

error

spacelabel

Space has Label

Only hide the content if the the current space has the specified label(s), eg. "meetings", etc.

string

error

teamlabel

Space has Team Label

Only hide the content if the the current space has the specified team label(s), eg. "sales,marketing", etc.

string

error

metadata

Page has metadata

Metadata associated with the current location in the format: "myKey1:myValue1, myKey1:myValue1, etc". when checking for a key with a specific value. To check for the existance of metadata with any value supply a commas separated list of key names, eg: "mykey1, mykey2, mykey3" or mix & match "mykey1, mykey2:myvalue2"

string

error

exists

Page Exists

Only hide the content if a specific page (referred to by the page title) exists. @parent can be used to hide data if the page is not at the root level, @child can be used to hide data if the page has children.

string

error

hastitle

Has Title

Only hide the content if the current page has a specific title

string

error

pluginkey

Plugin Enabled

The key of a plugin which must be enabled for the content to be hidden

string

error

space

Space Exists

Only hide the content if a specific space (referred to by the Space Key) exists.

spacekey

error

user

Username Is

Matches against the current user (NB: modified by withuser) - A comma separated list of usernames. Use @anonymous for anonymous users only, @creator for the creator of the current space, @author for the author of the current page.

string

error

group

Group Membership

A comma separated list of user groups that the current user (NB: modified by withuser) should be a member of

string

error

restriction

Page Restriction

Display content if the page has a restriction in place (none/view/edit/vieworedit/viewandedit - recursable)

string

error

permission

User has permission

A comma separated list of content permissions that the user must have (NB: modified by withuser).
Possible Options:

view - user has view permission
comment - user can add comments
createpage - user can create pages
createnews - user can create news
edit - user can edit pages or news
remove - user can remove (delete) pages, news or comments
attach - user can attach files
export - user can export pages or the space
createspace - user can create spaces
spaceadmin - user is a space admin
siteadmin - user is a site admin

string

error

useragent

User-agent

A comma separated list of tokens to match against the user agent string of the requesting browser.

string

error

attachment

Attachment

A comma separated list of filenames, one of which must be attached to the current page for the content to be displayed.

string

error

olderthan

Older Than

Content is hidden if the current page was modified before the given time period from the current date. The date is hidden in this format: olderthan=1y6m1d1h (year/month/day/hour)

string

error

newerthan

Newer Than

Content is hidden if the current page was modified after the given time period from the current date. The date is hidden in this format: newerthan=1y6m1d1h (year/month/day/hour)

string

error

ip

Requesting IP

A comma separated list of ip addresses to match against the request

string

error

skin

Current Skin

A comma separated list of skins one of which must be the current skin.

string

error

parameters

Request Parameters

The request must contain the key or key:value to match

string

error

locale

Locale

The users locale matches

string

error

resource

Resource

The named resource in SKINID::resource.ext or @current/@parent::resource.ext format exists

string

error

panel

Panel

A list of panels, one of which must exist and be enabled

string

error

recurse

Recurse

Should parent pages (if applicable) be checked for title, labels and metadata?

false - only check the current page (default)

true - also check parent pages, eg. does the current page or any of it’s parents have the specified label, etc.

boolean

false

error

spacekey

Space Key

The space against which permission checks will be made. Default is current space.

string

error

pagetitle

Page Title

The page against which permission checks will be made. Default is current page

string

error

withuser

With User

A username that user/group/permission checks should be run against. This includes: @anonymous, @creator, @author, @current

string

error

flag

Flag

A comma separated list of flags to check, will only hide if at least one of the flags is present</li>

string

error

notflag

Not Flag

A comma separated list of flags to check, will only hide if none of the flags are present</li>

string

error

Parameter Logic

  • While none of the parameters are mandatory, you must specify at least one of them for this macro to work.

  • For the macro content to hide, all contexts and modes specified must match.

    • In logic terms this means if you wish to test against two different parameters that may be exclusive you must use a hide macro for each list of parameters.

    • For example: testing against users and groups. A user must be in one of the groups mentioned or the logic will not work. If the user is not in a group mentioned in the parameters, test for the group permissions in the first panel-hide macro, then add another panel-hide macro inside that checks for the user names.

  • You can specify multiple values for any parameter, for example:

{panel-hide:mode=view,edit|context=page,blogpost}
stuff to hide
{panel-hide}

In the example above, "stuff to show" would only be shown if the content is being shown in "view" or "edit" mode and is also either a "page" or "blogpost".

Contexts, Modes and Decorators

You can determine the context and mode for any page by viewing the page source using your browser. A HTML comment output at the top of all pages shows the context and mode for each page.

Example

You can specify multiple contexts and modes by separating them with commas as shown in the usage example earlier. If you view the HTML source of a ThemeBuilder web page you’ll see similar to the following:

<!-- main.vmd
themebuilder : 'com.adaptavist.confluence.sitebuilder.SiteBuilderVelocityHelper@524c9770'/'$themebuilder.initialise'
spaceKey : 'USERGUIDE'
pageId : '10583'
currentURL : '/pages/viewpage.action?spaceKey=USERGUIDE&title=builder-show+macro&focusedCommentId=11666379'
contextPath : ''
spaceName : 'User Guides'
decorator : '$decorator'
printable : 'false'
mailId : '$mailId'
mode : 'view'
context : 'page'
-->

You can specify multiple contexts and modes by separating them with commas as shown in the usage example earlier.

Example

Hide content if the user is anonymous (not logged in).

<ac:macro ac:name="panel-hide">
<ac:parameter ac:name="user">@anonymous</ac:parameter>
<ac:rich-text-body>
You can only see this if you are logged in.
</ac:rich-text-body>
</ac:macro>
{panel-hide:user=@anonymous}
You can only see this if you are logged in.
{panel-hide}

Result Logged in users will see the message, anonymous users will not.

Resources

The panel-hide macro is based on the Theme Builder macro builder-hide, and you can use the same parameters and options.