How to hide/display content based on macro output?

Hi,

I'm having a section in my confluence page to display child pages. I want to display that section only if the macro {children} retrives any child pages. I'm not sure how to use the excerpt macro to get this result. Any help greatly appreciated.

Thanks in advance!

2 answers

1 accepted

1 vote
Davin Studer Community Champion Jan 12, 2014

You can do this pretty easily with a uer macro. Here is the code. This will create a user macro that you can wrap around the conditional content. If there are children to the page then that section will show, otherwise it will not.

Macro Name:
if_children

Macro Title:
If Children

Macro Body Processing:
Rendered

Template:
## @noparams
#if ($action.page.children.size() > 0)
$body
#end

0 vote
Andrei [errno] Community Champion Jan 12, 2014

I can only suggest tinkering with user macro + some velocity code.
Not sure how excerpts macro will help you.

also - referencing your Confluence version might be helpful

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

913 views 23 12
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you