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.
@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!
@Payal I'll give that a try and let you know. Thanks.
@Payal that almost works. It runs the blog titles all together and there is no cut off as to how many posts it shows.
Thanks - Kim
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.
@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!
@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.
Welcome to the Technology board!
Curious about our platform? Looking to connect on social technology? You've come to the right place!