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
Accepted answer
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

Thanks Davin!

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
Community showcase
Posted Oct 24, 2018 in Confluence

Atlassian Research opportunity with Confluence templates

Do you use templates with Confluence? Take part in a remote 1-hr workshop. You'll receive USD $100 for your time!   We're looking for people to participate in a   remote 1-hr workshop...

947 views 13 11
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