Forum Discussion

michael-r's avatar
11 years ago

Pulling Board Labels Into a Custom Component

Hi all, 

 

I'm looking to create a custom component that contains labels. So the scenario is that I have a board that uses a set of pre-defined labels and I'm looking to create a custom component which displays these labels - I am looking to display this within the ForumPage. I want the custom component to display these labels. I'm just not sure how I can pass calls for these labels into a custom component and if I can do this using the Community API?

 

Thanks, 

1 Reply

  • Hi michael-r 

     

    Yes, you can do this using the REST calls in a custom component, you can get the list of the predefined labels using below REST call,

     

    http://community.lithium.com/community-name/restapi/vc/boards/id/[id] /labels/predefined

     

    and make sure you have already added the labels in the board for which you want the above call to return the results.

     

    More info regarding this API call is here, https://community.lithium.com/t5/Community-API/bd-p/developers-rest-api?leaf-id=Board.labels#Board.labels.predefined

     

    Below is the sample code, Note that you may define the page_size if you want to limit the number of the results, otherwise, you can skip that.

     

    <#assign pre_lbl = rest("/boards/id/[id]/labels/predefined?page_size=10").labels>
    
    <#list pre_lbl.label as lbl>
    	${lbl.text}	
    </#list>

     

    Create a custom component, paste the above code, and place this component into the ForumPage from studios page tab, it should display the predefined labels inside the board you are in, if it has any.

     

    Let me know if this helps, or if you would like to get more details.