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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

897 views 23 12
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