Forum Discussion

gatomonstruo's avatar
4 years ago

Custom Component - Latest post by Role

Hey! 

This is my first time posting something here, so I'll be glad if you let me know if this is the proper board to do it or if some other place is more specific for this kind of question.

Currently, we have a Community which has 2 mains Category, completely independent.  We are running two different communities (divided by language) on the same platform.

And now I'm trying to personalize the 'Latest post' but using determinate roles for it. 

So, the normal LiQL should be something like 

 

SELECT id, subject, view_href, post_time, kudos.sum(weight), author.login, author.id, board.title FROM messages WHERE conversation.style = 'forum' AND depth = 0 ORDER BY post_time DESC LIMIT 10

 

 

But as you should guess, this retrieves all the posts from the whole community. 


Is there any way to use the current category as a filter? For example, some way that the liql identifies where I'm now and use that category id for the query? 

I was thinking to use JS to obtain the current URL and generate variables for the query, but I'm not sure how to proceed. 

Thanks in advance! 

Regards, 

  • Hi gatomonstruo ,

    You can use the ${coreNode.id} in Freemarker to get category ID, in the custom components.

    Following Is the reference document to get Core Node references:

    https://developer.khoros.com/khoroscommunitydevdocs/reference/corenode-1

    This will look something like following

    SELECT id, subject, view_href, post_time, kudos.sum(weight), author.login, author.id, board.title FROM messages WHERE category.id = '${coreNode.id}' AND conversation.style = 'forum' AND depth = 0 ORDER BY post_time DESC LIMIT 10

    Please Give Kudos if you find this post useful and also mark this as Accepted Solution if this is the required solution.

    Regards

    Tarun Kumar

  • Hi gatomonstruo ,

    You can use the ${coreNode.id} in Freemarker to get category ID, in the custom components.

    Following Is the reference document to get Core Node references:

    https://developer.khoros.com/khoroscommunitydevdocs/reference/corenode-1

    This will look something like following

    SELECT id, subject, view_href, post_time, kudos.sum(weight), author.login, author.id, board.title FROM messages WHERE category.id = '${coreNode.id}' AND conversation.style = 'forum' AND depth = 0 ORDER BY post_time DESC LIMIT 10

    Please Give Kudos if you find this post useful and also mark this as Accepted Solution if this is the required solution.

    Regards

    Tarun Kumar

  • gatomonstruo You can add category.id to your where clause

     

    SELECT id, subject, view_href, post_time, kudos.sum(weight), author.login, author.id, board.title FROM messages WHERE category.id = 'xxx' AND conversation.style = 'forum' AND depth = 0 ORDER BY post_time DESC LIMIT 10
    • gatomonstruo's avatar
      gatomonstruo
      Adept

      Hey peterlu

      Thanks for your reply! 

      Yes! I was thinking to do something like that, but by using 'category.id' the Query should display only content for that CatID. 

      So, the problem is that I need something dynamic, the component is need to be available for both communities environment, each with the results for that category. 

      Regards,