Forum Discussion

etisson's avatar
2 years ago

only show component if tkb article has a specific label

Hi All, 

I'm trying to develop a component that only shows up when a tkb article has a specific tag. 

I 'm new to freemarker and liql. 

This is what I have so far 

 

 

<#assign labels = webuisupport.path.parameters.name.get ("label-name","") /> 
<#if label??>
<#list labels as label>
${label.text}
</#list>
</#if>

<#if env.context.message.id??>
<#assign messageId = env.context.message.id
)>
<#else>
when-missing</#if>

 

Neither of these seem to retrieve the labels. 

Any idea's or solutions? 

Thanks

Kind regards,

Erik

  • etisson 

    This is an API to get lebels 

     

    <#assign labels = restadmin("2.0", "/search?q=" + "SELECT text FROM labels WHERE messages.id=${msgid}"?url).data.items![] />​

     

    You can iterate through the labels using a loop and implement specific conditions for particular labels.

  • Here you go 

    <#assign messageId = page.context.thread.topicMessage.uniqueId>

    Make sure you are adding it on message page as it will only work on message page. On rest of the pages, it will throw an error. 

  • etisson Based on your initial post I'm actually not sure if you are trying to limit by tags or labels? These are two different things ok Khoros Classic.

  • etisson 

    This is an API to get lebels 

     

    <#assign labels = restadmin("2.0", "/search?q=" + "SELECT text FROM labels WHERE messages.id=${msgid}"?url).data.items![] />​

     

    You can iterate through the labels using a loop and implement specific conditions for particular labels.

  • VikasB Thanks, The query seems to be working, but only if I specify a hard coded message id. 

     

    How do i get ${msgid} ?

     

    Thanks

    • VikasB's avatar
      VikasB
      Boss

      Here you go 

      <#assign messageId = page.context.thread.topicMessage.uniqueId>

      Make sure you are adding it on message page as it will only work on message page. On rest of the pages, it will throw an error.