Forum Discussion

catherine_OTX's avatar
13 years ago

calling a label name

Hi guys!

 

I think I have a pretty easy question for you. While I'm in a blog, there are a list of topics that I can click on. If I click on the topic, the page returns only articles related to that topic.  At the bottom of the entry is the text "Topic:" plus the name of the current topic - which is related to the label, correct? is there a way to return the name of the current topic through REST? Something similiar to coreNode.id? Maybe something like currentTopic.id?

 

Thanks so much! I appreciate your time.

 

Catherine

  • You could get the ID of the page, then use REST to pull the list of labels for that object.  I do this with articles not blogs, but something like:

     

    <#assign labels = restadmin("/blogs/id/" + blog_id + "/labels").labels />

     

    Then you can iterate over the labels.

    • Thank you for your response xorrkaz....sorry I have a further question....how do you match the page ID with the page's current label?

       

      Thanks!
      Catherine

      • xorrkaz's avatar
        xorrkaz
        Genius

        Assuming you have the blog_id (and I think you can use coreNode.id there), you can use the Freemarker code I provided to get the labels for the current blog.  Again, this works for TKB articles, but I have not tried blogs as yet.  You could try it out on stage.

  • KaelaC's avatar
    KaelaC
    Lithium Alumni (Retired)

    Hi Catherine -

     

    To get the id of the current thread (which is equal to the id of the root message)

     

    ${page.context.thread.topicMessage.id}

     

    This variable is only available on pages with a thread so you must first check for the page name or only put this call in component added to message pages. Those pages are:

    • BlogArticlePage
    • ContestSubmissionPage
    • ForumTopicPage
    • IdeaPage

    Another thing to keep in mind is that an article can have multiple labels so you should be prepared to deal with looping through a number of labels.  

     

    Hope that helps.