Forum Discussion

djksar's avatar
djksar
Maven
13 years ago

freemarker code for # of new private messages

Is there any freemarker code to pull the # of new private messages?  I'm creating content in the announcement module and would like to put that info.    Priviate Messages (2)   something like tha...
  • AdamN's avatar
    13 years ago

    Hi djksar,

     

    It is possible with a little help from the REST API. You can use the rest custom context object to make a call to the REST API to get the number of new messages for the current user. Then you can use FreeMarker to output the result.

     

    Perhaps something like:

     

    <#if user.registered>
    
    <#assign newNoteCount = rest("/users/id/${user.id}/mailbox/notes/inbox/unread/count").value />
    Private Messages (${newNoteCount!"0"})
    
    </#if>

     I hope this helps!