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

0 votes
Answer 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
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

866 views 2 13
Read article

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