Forum Discussion

leogomes's avatar
11 years ago

Display the latest 3 topics under each category?

Hello,

In the community page, how can i display the latest 3 topics under each category? Instead of the latest topic.

 

Can you give me an example?

 

Thanks for you help

  • Hey Leogomes,

     

    As far as I know, we currently don't have the ability to modify number of latest topics displayed under each category.

     

    You could, however, create your own component to do this using the restapis.

     

    Here are the steps to do this:

    1) Use the categories api to get all the categories in the community

    2) Use the topics recent with ?page_size=3 for each category to get the 3 most recent topics

     

    Here is a resource on building components in case you're not familiar with it.

     

    You could also add an idea to the Ideas Board to make the number of latest topics configurable.

     

    Hope this helps,

     

    Yuri

  • Hi leogomes ,

     

    Here is a sample code snippet that might help you out.

    <#assign latestTopics = rest("/categories/id/[id]/topics/recent?page_size=3&restapi.response_style=view").messages />
    <#list latestTopics.message as message >
    <#assign subject = message.subject />
    get other details
    </#list>

     

     

    Thanks,

    Sam

  • YuriK's avatar
    YuriK
    Khoros Expert

    Hey Leogomes,

     

    As far as I know, we currently don't have the ability to modify number of latest topics displayed under each category.

     

    You could, however, create your own component to do this using the restapis.

     

    Here are the steps to do this:

    1) Use the categories api to get all the categories in the community

    2) Use the topics recent with ?page_size=3 for each category to get the 3 most recent topics

     

    Here is a resource on building components in case you're not familiar with it.

     

    You could also add an idea to the Ideas Board to make the number of latest topics configurable.

     

    Hope this helps,

     

    Yuri