Confluence User Macro using conditional formatting based on value of parameter?

Hi

I've got an old style user-macro (based on wiki formatted templates - yes i know it needs to be updated to html) in confluence 4.3.7, within which I display some additional page metadata.

My user community is asking whether it's possible to only display (or remove) some elements of metadata when certain conditions are met (or not met).

Describing the desired end-state for my user-macro using some crude wiki pseudocode, it would look like

#set($ChildPageCount=$content.getChildren().size())
..
If ($ChildPageCount > 0) Then
{panel:title=Child Pages: $ChildPageCount|borderStyle=solid|borderColor=#3C78B5|titleBGColor=#eeeeee|bgColor=#ffffff}
...
... additional wiki / formatting here
...
{panel}
End if

...

Does anyone have any suggestions?

Thanks!

1 answer

1 accepted

Your pseudocode looks fine, and yes what's been asked of you is feasible to implement.

The Velocity code would need to be #if ... #else ... #end of course.

I've shared some of the user macros I've written, including the following one which shows code for versions suitable for Confluence prior to and following v4.

https://confluence.atlassian.com/display/DISC/Image+rollover

Excelent information CharlesH, your advice/examples worked perfectly! Many thanks :)

For the record here's how implemented the solution (again using wiki pseudocode)

..
#set($ChildPageCount=$content.getChildren().size())
..
#if ($ChildPageCount != "0") Then
{panel:title=Child Pages: $ChildPageCount|borderStyle=solid|borderColor=#3C78B5|titleBGColor=#eeeeee|bgColor=#ffffff}
...
... additional wiki / formatting here
...
{panel}
#end

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,831 views 27 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