Forum Discussion
Hi @Haidong.
I've taken over this component from another developer and to be honest I am still in the process of learning Freemarker and in particular what API calls work where, so I really appreciate your help.
The custom component in question is basically replacing the default topics list for each forum board. This was done to satisfy design requirements for the client. You can see what I mean at this link - http://saneforums.org/t5/Our-stories/bd-p/forum-001.
So I'm not 100% sure, but I believe "restadmin()" was used instead of just "rest()" because there are administrator/moderator only forum boards that need to be accessed. Access to these boards is managed through the use of Roles and if/else statements. Nonetheless, I will test on the staging server replacing the calls with just "rest()" and see if everything still functions.
Likewise, I'll remove the "restapi.response_style=view" part from the API call and make sure it all still works.
Now, in terms of the query itself, I've tried both your method and NicoB's method and they partly work.
The custom component also includes a call to generate the page navigation so I updated that call as well. So, using your example for the page navigation:
Old - <#assign resultSize = restadmin("/boards/id/${coreNode.id}/topics/count").value />
New - <#assign resultSize = restadmin("/boards/id/${coreNode.id}/search/messages/count?q=is_root:true").value />
And for the main API call:
Old - <#assign msgList = restadmin("/boards/id/${coreNode.id}/topics?restapi.format_detail=full_list_element&restapi.response_style=view&page_size=${page_size}&page=${page_number}").node_message_context />
New - <#assign msgList = restadmin("/boards/id/${coreNode.id}/search/messages/count?q=is_root:true&restapi.format_detail=full_list_element&restapi.response_style=view&page_size=${page_size}&page=${page_number}").node_message_context />
Changing the above correctly returns the page navigation, showing 3 pages and a link to each page.
The problem though is that it doesn't return any of the topic content itself, just a blank page. I've attached a screenshot which shows the result.
So it seems that the code which displays the topics doesn't work once I've changed the main API call:
<#list msgList.message as msg>
topics go here
</#list>
So I'm working my way through the API docs to figure out why it's not working but if you have any ideas on what needs to change here I'd be greatly appreciative.
Thanks
Nathan
Hi snaffle ,
There is no node_message_
http://<community_url>/restapi/vc/search/messages?q=is_root:true
I hope that it helps.
btw: it is tough to replace the whole message list component, it could be better to customize existing message list instead of creating one your own. maybe you can talk to the business user and understand their needs on this.
Related Content
- 2 years ago
- 4 years ago