Forum Discussion
Here is a little example code for you. It will display the latest 3 blog article teasers from all blogs in the community
<#assign messages = rest("/topics/style/blog/recent?page_size=3").messages /> <div class="recent-articles-container"> <#list messages.message as message> <div class="recent-article-wrapper"> <div class="article-header"> <div class="article-subject"><a href="${message.@view_href}">${message.subject}</a></div> <div class="article-posted-by"> <span class="author">Posted By <#if message.author.login != "" && message.author.login != "Anonymous"><@component id="common.widget.user-name" user="conv:${message.author.login}" /></#if></span> </div> </div> <div class="article-teaser"> <#if message.teaser?length gt 0> ${message.teaser} <span class="read-more"><a href="${message.@view_href}">Read More</a></span> </#if> </div> </div> </#list> </div>
- woodag14 years agoGuide
KaelaC / RickyS:
Thank you for the help. I'm finally getting around to trying this.
I put the code into a custom component on my stage server. In the preview it appears it is pulling in the three most recent posts from the various blogs in our community. How to I get it to pull from one specific blog only?And then, how do I create another that pulls from a discussion board or group of boards in the same category?
- KaelaC14 years agoLithium Alumni (Retired)
To pull from one blog change the first line to
<#assign messages = rest("/blogs/id/[your blog id here]/threads/recent ?page_size=3").messages />
- woodag14 years agoGuide
hit a snag trying to do this. tech had me change it to
<#assign messages = rest("/blogs/id/[your_blog_id_here]/topics/style/blog/recent?page_size=3").messages />
also for anyone else reading this, the final steps in order to have this Content to show up with the proper styling of its title were:
go into Admin > Content > Custom Content
create a new Custom CONTENT with the title you want shown on the page, and that calls this Custom COMPONENT with the following tag
<@component id="[custom_component_id_here]"/>
go back to Studio > Page and put the Custom CONTENT into the appropriate page
go back to Admin at the Community or Board level, Display > Page Layouts and reassign as needed
once pushed to production you will need to repeat the admin steps on your live site
Related Content
- 10 months ago
- 11 months ago
- 3 years ago
- 2 years ago
- 3 years ago