It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to hide/show content in a wiki page

Wikified Aug 11, 2011

Other than the hide-if or toggle-cloak macros, is there a way to hide part of a wiki page based on a condition. In this case I want to display one link if the page has a child page and a different link if there is no child page.

The hide-if macro can be set based on a page label value, so if there were a way to toggle the page label that might work.

4 answers

1 accepted

0 votes
Answer accepted
David Peterson Aug 11, 2011

Just FYI, the above would be several times faster with the following reporter instead:

{local-reporter:page:children}
  {text-sort:content:title}
  {local-reporter}

{local-reporter} is much faster than {content-reporter}

However, to get a single 'if has child' type query, I'd suggest this instead:

{report-block}
  {local-reporter:page:children}
  {report-header}Has children{report-header}
  {report-empty}Doesn't have children{report-header}
{report-block}

The reason for using {report-header} instead of {report-body} is that the {report-body} will be output for every child, not just if there is 'one or more'.

0 votes
Jo-Anne MacLeod Aug 11, 2011

Take a look at Adaptvists [Theme macro plugin|https://www.adaptavist.com/display/Builder/Macros], specifically builder-show/builder-hide, I believe that it will do what you want.

We use it when we want to display a warning if a user is not logged into Confluence yet.

0 votes
Kevin Buchs Aug 11, 2011

Do you want the link to point to the child page, if there is one?

0 votes
Kevin Buchs Aug 11, 2011

I was thinking of the reporting plugin. You can have it generate a link to a child page and other specified content if there is no child page. If this will work, then I can give an example.

{report-block}

{content-reporter:space=@self|types=+page|scope=@self > children}

{text-sort:content:title}

{content-reporter}

{report-body}Child Exists: {report-info:page:title|link=true} \\

{report-body}

{report-empty}No Child: [Go here instead|MyOtherPage]{report-empty}

{report-block}

This does these things

  1. get a list of all children pages of the current page
  2. sort them by their title
  3. for each one found, output its title as a hyperlink to that child page
  4. if none are found, put out a link to MyOtherPage.
Wikified Aug 11, 2011

Sure - please provide an example.

Thanks!

Kevin Buchs Aug 11, 2011

see above.^^

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

Confluence CVEs and common questions

Two vulnerabilities have been published for Confluence Server and Data Center recently: March 20, 2019 CVE-2019-3395 / CVE-2019-3396 April 17, 2019 CVE-2019-3398 The goal of this article is...

948 views 0 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you