Dashboard > Atlassian Plugins > ... > Macros > hide-if
  Atlassian Plugins Log In | Sign Up   View a printable version of the current page.  
  hide-if

Added by David Peterson , last edited by David Peterson on Jun 06, 2008  (view change)
Labels: 

{hide-if}

Plugin: Visibility Plugin

This macro will show its contents to the viewer if the context matches the parameters specified.

Usage

{hide-if:[parameters]}
Hidden content.
{hide-if}

Parameters

Name Required Default Description
type(s)
The (list of) page types. May be:
  • page
  • news
  • comment
  • spacedescription
display(s)
The (list of) display modes. May be:
  • default
  • printable
space(s)
The (list of) spaces this will be displayed in.
action(s)
The action taking place.
  • view - The content is editable and is currently being viewed.
  • edit - The content is editable and is currently being edited.
  • template - The content is a template being previewed.
  • dashboard - The content is the dashboard.
label(s)
The list of labels to test are present or absent. Syntax details.
header
The list of header "name:value" pairs to check for. This can either be of the form "name*:exact value" or "name::*regular expression".

For example, to check if the current browser is FireFox, set to 'header=User-Agent::.*Firefox.*' This will confirm that the 'User-Agent' header contains 'Firefox'. What headers are available will depend on the browser being used.

scope
(Since 1.6.0) List of pages, news items, etc which are in scope. If the content is a page, the scope can be expanded to their children, descendents or ancestors:
  • > children - The direct children of the specified page. E.g. 'scope=My Page > children'
  • > descendents - All descendents of the specified page. E.g. 'scope="My Page" > descendents'
  • > ancestors - All ancestors of the specified page. E.g. 'scope=My Page > ancestors'
trim
true
If set to false, the content will not be trimmed before being output (if appropriate).
match
any
If set to 'all', then all items listed must match.

See Also

  • What version were each of the above parameter successfully implemented in? I am having trouble with the scope=xxxx. It simply does not hide.
  • is the hidden 'markup' 'executed' and then hidden, or NOT executed. For example, should the add-label macro be executed at all?

{hide-if:scope=spacekey:pagename}{add-label:application}{hide-if}

The behaviour I'm seeing is that the label is added to the page, even if the page name is in scope.

  • if I replace the 'add-label' with text, the text is still shown.

I'm trying to have a label as part of a zone-template. If the page is included in another, then the label will be added, but I don't want the label added to the zone-template itself. So basically, if the wiki code is executes on the page called 'pagename', don't add a label. any other page is fair game.

  • note: using display=default will successfully 'hide' the add-label action, so I think the 'scope' parameters is not working for me.

Hi James,

  • I'm not certain when the parameters were added, but scope has been around for quite a while, possibly from the beginnning.
  • The hidden markup is not executed.

The test below does this:

{hide-if:scope=hide-if}This should not be displayed.{hide-if}
{show-if:scope=hide-if}The current page is [hide-if]{show-if}

Result:

The current page is hide-if

This would indicate that it is working on this site. If your page name has spaces, its probably best to put it in quotes. Eg: {hide-if:scope="KEY:Page Name"}

If you're still having trouble, could you post your exact wiki markup? Alternately, create abug report and we'll follow up there.

Hi,

i do not understand the "action" parameter. Can you post a use-case or example code how this parameter can be used?

Thanks a lot!

{hide-if:action=edit}
This will be shown in edit mode only!
{hide-if}

Something like that will mostly be used in combination with scaffolding.

Thank you, Christian!

That was my problem: This macro parameter only works in combination with the scaffolding plugin!

I'm having trouble hiding text from the printable view (Confluence 2.9.1, IE6). The "hidden" line shows when printed but not when exported to PDF (leading me to believe it's an IE6 bug). Thoughts?

{hide-if:display=printing}
Content that should not be printed
{hide-if}

Hi Dylan,

The condition works if the page is being viewed in "printable" view. For whatever reason, Confluence does not actually provide an obvious way to access this view. You can do so by appending ?decorator=printable to the end of the URL of the page you wish to print and it will redisplay the page, this time with the content hidden properly. If you print this page the content will not be printed. This "bug" is applicable to all browsers, not just IE6.

I have raised this issue in the bug tracker at http://jira.adaptavist.com/browse/VISIB-58 - if you think this is important, please vote for it so that we can schedule it into a future release.

Hope that helps,
Jennifer

Thanks for the info. I got the desired result by using the noprint class from print.css:

{html}
<span class="noprint">
{html}
Text that won't appear in the printed version.
{html}
</span>
{html}
Copyright(c) CustomWare Asia Pacific Pty Ltd
Powered by Atlassian Confluence 2.7.3, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators