Public
Honored Contributor

Display a conglomeration of blog posts in a category

We have various categories with sub-categories under those.   Those sub-categories have blogs.   

What I would like to do is have a "Latest Blog Posts" widget in a category page that shows a conlomeration of recent blog posts only under that category.   Is that something relatively easily doable?   

We do have them-lib.latest-blogs on our home page that does the same thing for the entire community.  Would that do what I want at a category level?

Thanks in advance. 

--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.
6 Replies 6
Honored Contributor

@kgroneman - To display the blog posts in a particular category, you need to make a custom component and use the following rest call:

<#assign blogPosts = rest( "2.0", "/search?q=" + "select * from messages where category.id = 'CATEGORY-ID' and conversation.style='blog' and depth= 0 order by post_time DESC"?url).data.items />

<#list blogPosts  as getPost>

${getPost.subject}

</#list>

 

You just need to add the category id and then add this component to the desired category page.

 

Please let me know if this works for you.

Thanks!

 

Honored Contributor

@Payal  I'll give that a try and let you know.  Thanks.

--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.
Honored Contributor

@Payal that almost works.   It runs the blog titles all together and there is no cut off as to how many posts it shows.

  • How would you get that to display each blog subject on a new line?
  • How would you get that to show only a certain number (such as 5) posts?

Thanks - Kim

--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.

I got one per line by putting a paragraph tag in the list:

 

<p>${getPost.subject}

 

Still don't know how to truncate it to 5 posts.   Also I need the post titles to be links.   This just lists the titles.

--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.
Honored Contributor

@kgroneman - You can use the following code for limit and links:

 

<#assign blogPosts = rest( "2.0", "/search?q=" + "select * from messages where category.id = 'CATEGORY-ID' and conversation.style='blog' and depth= 0 order by post_time DESC LIMIT 5"?url).data.items />

<#list blogPosts  as getPost>

<a href="${getPost.view_href}">${getPost.subject}</a>

</#list>

 

 

Please let me know if this works.

 

Thanks!

Honored Contributor

@Payal that's starting to look better, but at the same time I did some testing with adding:

<component id="theme-lib.latest-blogs"/>

 to the page and found it is category heirarchy specific and I like the way it displays the blog posts so I'm going with that one.  I really apprecaite your time.  I learned some things. 

--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.

Welcome to the Technology board!

Curious about our platform? Looking to connect on social technology? You've come to the right place!

Are you a Khoros customer? For direct assistance from our Support team, please visit the Support Forum.