hobbs6487
13 years agoHelper
Author's Kudos of Current Post
I am trying to implement a kudos count of the author who wrote the current post in a board. Currently, whenever I make this call (Where max is equal to the number of posts in the board): <#list ...
- 13 years ago
Hi hobbs6487,
When your component is in the context of a message, you can use the env FreeMarker custom context object to obtain the user id of the message author:
env.context.message.author.id
Once you have the user's id, it's just a matter of sticking that in the appropriate REST API call to get the kudos count for that user, for example:
<#assign kudosCount = rest("/users/id/${env.context.message.author.id?c}/kudos/received/count").value!"0" />
Once you've assigned the value to a variable, you can manipulate it as needed, or just output it for display:
Kudos: ${kudosCount}
Some references you may find useful:
http://lithosphere.lithium.com/t5/Developer-Knowledge-Base/Context-objects-for-custom-components-env/ta-p/9321
http://lithosphere.lithium.com/t5/Lithium-Developers/Display-user-s-real-name-instead-of-user-handle/m-p/31323/highlight/true#M344I hope this helps!
-Adam