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

Gavin Fowler
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.
March 26, 2013

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
CharlesH
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.
March 27, 2013

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

Gavin Fowler
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.
March 27, 2013

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
TAGS
AUG Leaders

Atlassian Community Events