Forum Discussion

skylinegtr's avatar
10 years ago

Forum Thread Layout

Hello!

 

I was checking out this site: http://community.k2.com/ and I really like the thread layout shown below.  I would like to do something like this. Any tips on how I can create something like this? I assumed creating a custom component and API (if you have an API code that you can share, it would be awesome).

 

 

Any help would be greatly appreciated.

Thanks!

  • Hi skylinegtr,

     

    Try this

    <#assign messageList = rest("/categories/id/mahesh_revanwar/search/messages?q=is_root:true&sort_by=-views&restapi.response_style=view").messages.message />
    
    <#list messageList as msg >
    	<a href="${msg.@view_href}">${msg.subject}</a>
    	<br>
    	<#assign avatar = rest("${msg.author.@href}/profiles/avatar").image.url>
    	Avatar: <img src="${avatar}">
    	Author : ${msg.author.login}
    	<br>
    	Date : ${msg.post_time.@view_date} | ${msg.post_time.@view_time}
    	<br>
    	Views : ${msg.views.count}
    	<br>
    	<br>
    </#list>

    Regards,

    Mahesh Revanwar

     

    If my post is helpful and answers your question, please give "Kudos" and "Accept it as a Solution."

  • Hi skylinegtr,

     

    You need to change variable name which is correct, as if you consider example provided by mahesh_revanwer the looping is done with "msg" variable used. Considering this variable you can write a code as follows:-

    <#assign replyCount = rest("${msg.thread.@href}/replies/count").value>
    ${replyCount}

    As the "topic" variable is not present in your code error got generated.

     

    Regards,

    Vishwajit Shinde

     

    If my post is helpful and answers your question, please give "Kudos" and "Accept it as a Solution."

13 Replies

  • skylinegtr's avatar
    skylinegtr
    Mentor
    10 years ago

    vishwajit_shind-Thank you for helping me with this. I've tried the rest api that you provided. It's giving me an error, I've tried to modify/make changes to the code as well but still get an error. 

     

     

    FreeMarker template error

    The following has evaluated to null or missing:
    ==> topic  [in template "preview" at line 2, column 466]
    
    Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??

     

  • vishwajit_shind's avatar
    vishwajit_shind
    Expert
    10 years ago

    Hi skylinegtr,

     

    You need to change variable name which is correct, as if you consider example provided by mahesh_revanwer the looping is done with "msg" variable used. Considering this variable you can write a code as follows:-

    <#assign replyCount = rest("${msg.thread.@href}/replies/count").value>
    ${replyCount}

    As the "topic" variable is not present in your code error got generated.

     

    Regards,

    Vishwajit Shinde

     

    If my post is helpful and answers your question, please give "Kudos" and "Accept it as a Solution."