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

This widget could not be displayed.

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
Posted Monday in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

516 views 7 6
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