How to hide/display content based on macro output?

Avinash January 12, 2014

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
Answer accepted
Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 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

Avinash January 12, 2014

Thanks Davin!

0 votes
Andrei [errno]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 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
TAGS
AUG Leaders

Atlassian Community Events