[CONFLUENCE] Is there some Velocity code I can use to check whether a page has children?

Steve Goldberg
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.
August 19, 2012

I have a macro I'm writing that would be improved by a conditional that will execute code based on whether a page has children. Does anybody know how to do this?

2 answers

1 accepted

1 vote
Answer accepted
Remo Siegwart
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.
August 20, 2012

If you have a page object you can call:

#if($page.hasChildren())
    ## do some magic
#end

See the page API documentation for more information.

Hope this helps

0 votes
Steve Goldberg
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.
August 20, 2012

I see that you can use .hasChildren but $page.hasChildren() did nothing. After some poking around, I found that $content.hasChildren() works just fine.

Thanks Remo!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events