Forum Discussion

jaread83's avatar
jaread83
Champion
9 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:

6 Replies

  • Or even just the pre-defined list... that would work too...

    Any help is appreciated.

    Cheers

  • ClaudiusH's avatar
    ClaudiusH
    Khoros Alumni (Retired)
    9 years ago

    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
    9 years ago

    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)
    9 years ago
    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.
  • jaread83's avatar
    jaread83
    Champion
    9 years ago

    Thank you both for the helpful replies. I ended up using the component that Claudius suggested and hacked at it with some CSS to make it do what I needed it to do (become 'tabbed' navigation for the blog).

    The only issue i can see doing it this way is that if you have the normal blog labels and the other one on the same page, the settings are shared on both. Not such a big issue as i am only ever using one version of the component but i thought i would flag it up.