How to build a custom thread list for display in message-list-panel
I've been trying to build a custom component that will display only unanswered threads authored by paying customers. Our paying customers have a role assigned to them "customer", so I'm querying the REST API for a list of unanswered posts, then identifying the author of each post, querying the roles of said author, then if they have the correct role, I want to append that thread to my sequence variable, which I will feed to the "forums.widget.message-list-panel" component for display.
Here's my code snippet:
<#list rest("/search/messages?openresponse=true&sort_by=-topicPostDate&page_size=" + results_list_size).messages.message as message> <#assign author = message.author.login> <#assign authorID = restadmin("/users/login/${author}/id").value> <#list restadmin("/users/id/${authorID}/roles").roles.role.name as authorRole> <#if authorRole?? && (authorRole == "customer")> <#assign messagelist = messagelist + message>
When I save this code, Studio throws this exception:
FreeMarker template error Only elements with no child elements can be processed as text. This element with name "message" has a child element named: thread The failing instruction (FTL stack trace): ---------- ==> #assign messagelist = messagelist + m... [in template "preview" at line 27, column 7] ----------
But if I change my message variable to drill down to the "thread" node level, by changing this line:
<#assign messagelist = messagelist + message>
to this:
<#assign messagelist = messagelist + [message.thread]>
it complains that my right-hand operand is not convertible to a string:
For "+" right-hand operand: Expected a string or something automatically convertible to string (number, date or boolean), but this evaluated to a sequence (wrapper: f.t.SimpleSequence): ==> [message.thread] [in template "preview" at line 27, column 44] The failing instruction (FTL stack trace): ---------- ==> #assign messagelist = messagelist + [... [in template "preview" at line 27, column 7] ----------
What am I doing wrong? In other languages, this is just an array that I'm trying to append to, but Freemarker doesn't seem to like that.
Ultimately, I just want to display this custom-built list of unanswered threads with this code:
<div class="lia-panel lia-panel-standard top-five-threads-with-no-replies-wrapper"> <@component id="forums.widget.message-list-panel" title="${message_list_title}" messages="rest_v1:"+messagelist style="wide" numMessages="conv:"+results_list_size /> </div>