Forum Discussion

bartgoris's avatar
8 years ago

Topic page - user badges

Hi,

 

Does someone know how i can get recently earned badges / user on the topic page?

 

Kind regards,

Bart

  • Hi Payal,

     

    Thank you for the quick reply.


    I tried the following, but it gives me an empty result:

    <#assign topicBadges=rest("/users/id/279/badges?user_badges.sort_order=earned_date_desc").users />

    <#list topicBadges.user_badges as topicBadge>
    ${topicBadge.badge.icon_url}
    </#list>

     

    Do you know what I did wrong?

     

    Kind regards,

    Bart

  • Payal's avatar
    Payal
    8 years ago
    Hi bartgoris,

    I have made some changes to your code. Please try the following code and let me know if this works for you.

    <#assign topicBadges = rest("/users/id/279/badges?user_badges.sort_order=earned_date_desc").user_badges />
    <#list topicBadges.user_badge as topicBadge>
    ${topicBadge.badge.icon_url}
    </#list>

    Hope this helps!!

    Thanks,
    Payal

3 Replies

  • Hi bartgoris,

    For this, you have to create a custom component and use the following API to get recently earned badges for users:

     

    community.myCommunity.com/restapi/vc/users/id/[userID]/badges?user_badges.sort_order=earned_date_desc

     

    Add this component to ForumTopicPage.

    Hope this helps!!

     

    Thanks,
    Payal

  • bartgoris's avatar
    bartgoris
    Guide
    8 years ago

    Hi Payal,

     

    Thank you for the quick reply.


    I tried the following, but it gives me an empty result:

    <#assign topicBadges=rest("/users/id/279/badges?user_badges.sort_order=earned_date_desc").users />

    <#list topicBadges.user_badges as topicBadge>
    ${topicBadge.badge.icon_url}
    </#list>

     

    Do you know what I did wrong?

     

    Kind regards,

    Bart

  • Payal's avatar
    Payal
    Director
    8 years ago
    Hi bartgoris,

    I have made some changes to your code. Please try the following code and let me know if this works for you.

    <#assign topicBadges = rest("/users/id/279/badges?user_badges.sort_order=earned_date_desc").user_badges />
    <#list topicBadges.user_badge as topicBadge>
    ${topicBadge.badge.icon_url}
    </#list>

    Hope this helps!!

    Thanks,
    Payal