Forum Discussion

KaelaC's avatar
KaelaC
Lithium Alumni (Retired)
12 years ago

Creating an "In Reply To" custom component and adding it to messages

 

When listing messages in linear view it can be difficult to tell which message a reply is in response to.  This litle bit of code will create a custom component that you can place in a Forum Message quilt to help link the reply with the parent post.

 

In Studio, create a custom component :

 

<#if env.context.message.uniqueId gt 0> <#-- check to see if we have a message -->

<#assign root = restadmin("/messages/id/${env.context.message.uniqueId?string.computer}/root?restapi.response_style=view").message> <#-- get that message from rest -->

<#assign parent = restadmin("/messages/id/${env.context.message.uniqueId?string.computer}/parent?restapi.response_style=view").message> <#-- get the parent message from rest -->


<#if parent.@null[0]?? && parent.@null=="true"> <#-- check to make sure a parent exists -->

<#-- if no parent you can put some text here or nothing -->
<#else>

        <div class="reply-to">

    <span class="reply-author"><a href="${parent.@view_href}">in reply to</a>

                ${parent.author.login}</span>
        </div>
        </#if> <#-- end parent check -->
</#if> <#-- end message context check -->

 

 

Now go to the Page tab in Studio and select Forum Message.  This quilt represents each individual message on a thread page.  Add your new component in. I like to put it right under the message header.  Save and Test.  You should see something like this:

 

inreplyto.PNG

  • Looks good.
    Do you have examples where this is in use? Would be interested how it turns up in UI.

    Also: Any possible performance impact by these additional rest calls for each message when viewing a topic page with 20 messages?