Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Deprecation of $content.getLabelUtil()

My Macro:

 

## @noparams

<div id="related-content">

<script language=javascript>

function toogle(divname) {
if (document.getElementById(divname).style.display != "block") { document.getElementById(divname).style.display = "block"; }
else { document.getElementById(divname).style.display = "none"; }
}
</script>

#if($content.getIdAsString()!='4161541')
#set($wiki="")
#set($globalHelper=$action.getHelper())
#if($content) ## i. e. we render a normal page
#set($renderer=$globalHelper.getWikiStyleRenderer())
#set($context=$content.toPageContext())
#set($labelList=$content.getGlobalLabels($action.getRemoteUser()))
#if($labelList.size() > 0)
#set($labelUtil=$content.getLabelUtil())
#set($labels=$labelUtil.convertToDelimitedString($labelList))
#set($labels="'"+$labels+"'")
#set($labels=$labels.replace(" ","','"))
<h1><a href="javascript&colon;;" onclick="toogle('rcontent');">Sider med lignende indhold</a></h1>
<br>
<div id="rcontent" name="rcontent" style="display:block;">
<ac:structured-macro ac:macro-id="e5bbc54f-287e-447c-9e9e-f84af88ad353" ac:name="contentbylabel" ac:schema-version="2">
<ac:parameter ac:name="showLabels">false</ac:parameter>
<ac:parameter ac:name="cql">label in ($labels) AND label != "noshow"</ac:parameter>
</ac:structured-macro>
</div>
#end
#end
#end
</div>

 

Is not working in C7, seems $content.getLabelUtil() is deprecated.... https://confluence.atlassian.com/doc/deprecated-code-paths-removed-in-7-0-967879993.html

 

Ok, what do I do? Ad get whats possible with $content ? All I find is C6.6 related

1 answer

0 votes
Diego Atlassian Team Oct 28, 2019

Hello, @Normann P_ Nielsen _Netic_ !

I understand that is can be quite troubling when something is deprecated or completely removed from an array of tools that we are accustomed to using.

The content.getLabelUtil() method has been deprecated in a previous version of Confluence. Confluence 5.2, to be more precise. Here you can check this information:

 

Here is a screenshot of that page:

Anotação 2019-10-28 171136.jpg

 

According to the deprecation notice, we should start using LabelUtil directly. Here is a link to it:

 

If you need further assistance with developing questions, you can reach to our Developer Community, Normann. Here, take a look!

 

Let us hear from you!

As in: #set($labels=$content.LabelUtil().convertToDelimitedString($labelList)) ?

 

That does not work ...

@Normann P_ Nielsen _Netic_were you able to figure out how to properly access the class LabelUtil?

@Federico 

 

Long time ago - my current code is:

 

## @noparams

<div id="related-content">

<script language=javascript>

function toogle(divname) {
if (document.getElementById(divname).style.display != "block") { document.getElementById(divname).style.display = "block"; }
else { document.getElementById(divname).style.display = "none"; }
}
</script>

#if($content.getIdAsString()!='4161541')
#set($wiki="")
#set($globalHelper=$action.getHelper())
#if($content) ## i. e. we render a normal page
#set($renderer=$globalHelper.getWikiStyleRenderer())
#set($context=$content.toPageContext())
#set($labelList=$content.getGlobalLabels($action.getRemoteUser()))
#if($labelList.size() > 0)
#set($labels="")
#foreach( $label in $labelList )
#if($labels == '')
#set($labels="'"+$label+"'")
#else
#set($labels=$labels+","+"'"+$label+"'")
#end
#end
#set($labels=$labels.replace(" ","','"))
<h1><a href="javascript&colon;;" onclick="toogle('rcontent');">Sider med lignende indhold</a></h1>
<br>
<div id="rcontent" name="rcontent" style="display:block;">
<ac:structured-macro ac:macro-id="e5bbc54f-287e-447c-9e9e-f84af88ad353" ac:name="contentbylabel" ac:schema-version="2">
<ac:parameter ac:name="showLabels">false</ac:parameter>
<ac:parameter ac:name="cql">label in ($labels) AND label != "noshow"</ac:parameter>
</ac:structured-macro>
</div>
#end
#end
#end
</div>

Thanks @Normann P_ Nielsen _Netic_ . I was looking so hard at utilizing the actual method that totally overlooked the option to just iterate thru the list. What can I say, works for me!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

🏑 Atlympic Event: Confluence

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

494 views 18 17
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you