Forum Discussion

jaread83's avatar
jaread83
Champion
8 years ago

REST api for most used blog labels

I am looking at creating a custom component using blog labels and having them filter the blog articles down to the most popular categories.

What I need is to list out the top 5 most used labels and display them as links to filter the blog.

I have tried using the api but no such luck getting it to output anything.

Any ideas on how to get the most used blog labels to be displayed into my component?

 

  • Hi jaread83

    In order to obtain the most popular labels the API v2 labels would need to support both GROUP BY and SORT, which unfortunately they don't yet.

     

    But there is some good news: You might actually not need to create a custom component. Take a look at the Lithium Studio documentation of the updated responsive labels widget labels.widget.labels-list as it allows for sorting and limiting the output to 5 labels as well:

  • ClaudiusH's avatar
    ClaudiusH
    Khoros Alumni (Retired)

    Hi jaread83

    In order to obtain the most popular labels the API v2 labels would need to support both GROUP BY and SORT, which unfortunately they don't yet.

     

    But there is some good news: You might actually not need to create a custom component. Take a look at the Lithium Studio documentation of the updated responsive labels widget labels.widget.labels-list as it allows for sorting and limiting the output to 5 labels as well:

    • jaread83's avatar
      jaread83
      Champion

      Hi ClaudiusH, that seems to work just great. But is there a way to set the default sorting options? All I can see there is to set the sortable filter on or off...

      • ClaudiusH's avatar
        ClaudiusH
        Khoros Alumni (Retired)
        I couldn't find any parameters to change the default sorting. Luckily for your scenario the OOTB default for the widget with enabled headers seems to be "Top Labels", i.e. sorted by volume descending.
        I would recommend to create a new product idea explaining the rationale of how you would see a sorting parameter for this widget to be useful.
  • Or even just the pre-defined list... that would work too...

    Any help is appreciated.

    Cheers