Forum Discussion

rupamkhaitan's avatar
11 years ago
Solved

How can I extract latest topics across all forums inside a category page

I have a category page which has 4 sub-forums inside.

I want to pull all the latest topic inside my custom component, just the way lithium component does (Latest Topic Component)

 

I dont see direct URL which does that for us

 

something like http://community.lithium.com/community-name/restapi/vc/categories/id/[id] /boards

But it ask for board id further to pull all the threads inside that board, what i am looking for is if i have multiple boards inside a category i want to pull all the latest threads inside that category with one API call.

 

 

Please help.

6 Replies

  • rupamkhaitan's avatar
    rupamkhaitan
    Helper
    11 years ago

    I tried that but it doesnt give me all the threads inside each forum page for one category page.

     

    For eg: I have one category page with ID : cat1

                Inside this category i create four forum with ID: F1, F2, F3, F4

     

     

    Now i want all the latest topic to be pulled from each forum in one component, i have achieved this by looping through each forum and rendering the HTMl, but i was wondering if there is any straight forward way with one URL which gives the consolidated information.

     

     

    There is a built-in component in lithium saying 'Latest Topic' which does what i am looking for, but thats the built component and I want a custom component with similar feature.

     

     

    Putting /nested in the URL is not giving me all the threads for each forum.

     

     

    please help

  • sunny_mody's avatar
    sunny_mody
    Advisor
    11 years ago

    Hi,

     

    I believe this rest api should work for you :

     

    /restapi/vc/categories/id/{category_id}/topics/recent

     

    Thanks,

    Sunny

  • this doesnt work because we have sub-category inside each category.

    And each sub-category has forum pages.

    Under each forum page we have threads/messages

    And i want to get all the messages/threads from each forum under each sub-category.

     

     

    The only way I could achieve this is by looping

     

    <#list rest("/categories/id/{CATEGORY_ID}").category.categories.category as category>

    <#list rest("/categories/id/{CATEGORY_ID}/${category.@href}").category.boards.board as board>

    <#assign threads = rest("/categories/id/knowledgebase/${category.@href}/${board.@href}/threads/>

    </#list>
    </#list>

     

     

    So now my threads variable has all the data for each forum under each sub-category.

     

     

    Cheers

    Rupam