Forum Discussion

swamyandfriends's avatar
swamyandfriends
Contributor
9 years ago

Get latest discussion topics based on Category

Hi ,

 

I need to get the latest discussion topics based on a category . Eg : Get latest topics on Music .

How can i get using Liql Query ?

 

Please let me know if there are any other way of getting it .

 

Thanks in advance !!!

  • ChhamaJ's avatar
    ChhamaJ
    Khoros Staff

    Hi  swamyandfriends,

     

    To get the latest topics in a category you need to run the following LiQL query 

    SELECT * FROM messages where category.id = 'music' and depth=0 order by post_time desc

    This will give you just the topics. If you need replies as well, just remove the depth=0 clause.

     

    Hope this helps.


    Regards,
    Chhama

     

    • swamyandfriends's avatar
      swamyandfriends
      Contributor

      hi thanks for your reply ,
      I found that the levels are categories as .
      Categories -- > Inside categories there are many boards -- > inside boards there are many discussion topics .

      If i want to get the discussion topics inside a specific category (not boards) , the above query which you said will help .

      But , initially i need to get the list of categories . Can you help me to get that ?

      Doubt:
      If i use the above query , will i get all the topics in all the boards which are under music category ?

       

      One more question :

      Am getting the topics based on category id , will the category be deleted in the future ? If it is deleted how to handle these kind of cases ?

      • ChhamaJ's avatar
        ChhamaJ
        Khoros Staff

        To get the categories in a community, you need to do 

        Select * from categories
        OR
        Select id from categories

        Regarding your doubt, yes you will get all the topics in all the boards under music category using the query provided.

         

        If the category is deleted, then all the boards and topics under that category are also deleted (unless you move them before deleting the category in which case you will have to manually correct the query)

         

        Hope this helps.

         

        Regards,
        Chhama