Hello,
the below usermacro is working fine on all spaces which I enter as parameters. But it does not work if I enter the current space as parameter. What's going wrong? Something wrong with "containerContext" ?
Thanks for any hint.
Bye
Sven
BTW: If someone knows how to pass in the labels as a parameter (list separated with ",") and how to check in the if-condition against this list, you are welcome, too...
## @param spacekey:title=Spacename|type=spacekey|required=true|desc=Spacename|default=template ## @param maxresults:title=Maximale Anzahl|type=string|required=true|default=30 #set($containerManagerClass=$action.class.forName('com.atlassian.spring.container.ContainerManager')) #set($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null)) #set($containerManager=$getInstanceMethod.invoke(null,null)) #set($containerContext=$containerManager.containerContext) ##com.atlassian.confluence.labels.actions.RankedNameComparator #set($RankingComparator=$action.class.forName('com.atlassian.confluence.labels.actions.RankedNameComparator').newInstance()) #set($labelManager=$containerContext.getComponent('labelManager')) #requireResource("confluence.macros.advanced:popular-labels-resources") <div class="heatmap"> <ul> #foreach( $pLR in $labelManager.getMostPopularLabelsWithRanksInSpace($paramspacekey, 30, $RankingComparator) ) #set( $n = $pLR.label ) #if ( !($n == "sv") && !($n == "hometab") && !($n == "metatocheck") && !($n == "prio1") && !($n == "prio2") && !($n == "prio3") && !($n == "prio4") && !($n == "prio5") && !($n == "s_init") && !($n == "s_30") && !($n == "s_60") && !($n == "s_done") ) #set ($size = 12 + $pLR.rank * 2) <li style="font-size:${size}px;">#labelLink($pLR.label)</li> #end #end </ul> </div>
Community moderators have prevented the ability to post new answers.
Hello,
your code is working for me also with current space as parameter! I have no spaces or special chars in my space name.
Additional, I have tried this adaption to take empty spacekey (required=false and no default value) as current space and it is working for me too:
#set($spacekey=$space.key) #if($paramspacekey) #set($spacekey=$paramspacekey) #end
Labels as parameter list (one suggestion):
## @param labels:tilte=Labels|type=string #foreach($label in $paramlabels.split(",")) $labelManager.getContentCount($labelManager.getLabel($label))) #end
Thank you for your example with using LabelManager!
Bye,
Tilmann
Thanks a lot for trying.
Strange thing: On another space it is working for me, too ;-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.