Forum Discussion

skylinegtr's avatar
9 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."

  • Hi skylinegtr,

     

    You can try this REST call:

    <community-base-url>/restapi/vc/categories/id/forums/search/messages?q=is_root:true&sort_by=-views&restapi.response_style=view

    using this call you get the all messages in sorted with respect to views else part can be handle using html and css.

     

    Regards,

    Mahesh Revanwar

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

     

    • skylinegtr's avatar
      skylinegtr
      Mentor

      mahesh_revanwar-Thank you for your help. It's not working for me, so I'm doing something wrong on my end. Can you provide me step by step on how to set it up? Just need to get the API part to work. HTML and CSS I can do. 

       

      If you can, I would be very greatly appreciated. Thanks in advance.

      • mahesh_revanwar's avatar
        mahesh_revanwar
        Expert

        Hi skylinegtr,

         

        Please try this code

        <#assign messageList = rest("/categories/id/<category_name>/search/messages?q=is_root:true&sort_by=-views&restapi.response_style=view").messages.message />
        
        <#list messageList as msg >
        	${msg.subject}
        	<br>
        </#list>

        from this you can list down all the message titles. Same like this you can fetch all other values related to message.

         

        Regards,

        Mahesh Revanwar

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