Forum Discussion

woodag's avatar
woodag
Guide
14 years ago

Cross promote blogs and discussion boards

Want to add a Widget to my blog pages that lists recent topics on our discussion boards, and vice versa.  Is this a widget Lithium has pre-built, and if so how to get it on the appropriate pages? I don't see "Choose Sidebar Widgets" on my blog pages anymore.

  • KaelaC's avatar
    KaelaC
    Lithium Alumni (Retired)

    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>

     

     

    • woodag's avatar
      woodag
      Guide

      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?

      • KaelaC's avatar
        KaelaC
        Lithium 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 />

         

         

  • RickyS's avatar
    RickyS
    Lithium Alumni (Retired)

    Hi woodag,

     

    There isn't a pre-built widget available that'll do what you're asking.  Just to make sure I understand correctly, you'd like to show a widget with recent board posts to show on your blogs pages and a recent blog articles widget to display on your discussion board pages?

     

    If that's the case, your best bet is to create custom content via the Community Admin tool or custom components via Lithium studio that creates widgets as described above.  You're limited to the number of custom content you can create (9 content areas total) but the custom content code can be node-specific - meaning, you can have different custom content code for different levels of your community.  Custom components are built in Studio and are the same community-wide.  This thread does a much better job of explaining the difference. 

     

    In your case, I would recommend going with Custom Component via Studio.  If you're not already, you'll have to familiarize yourself with our Rest API documentation.

     

    Latest Rest API Documents can be found in this TKB article.  Studio documentation: Studio TKB.  We recently put together a series of training videos on how to use Studio Advanced.  If you'd like to view these training videos, please submit a case ticket requesting access to this valuable resource.

     

    For each widget you build, you can specify which specific category or board you'd like to pull the most recent discussion topics or posts, and same for blogs, you can specify where you want to pull your latest articles or comments.  You can also specify your Rest API calls to pull up content based on other criteria like "featured topic" - a designation you can add to content in your boards you'd like to highlight or "feature".  This is only a backend setting and won't show anything on the community front-end if you mark a topic or blog article as featured.  But this option gives you a little bit more editorial control over what content you'd like to display in the blog/board widgets you want to create.

     

    Once you determine which Rest API calls you want to incorporate into your widget, you'll have to add the styling html and css code within the custom content code to format and present the XML data properly, consistent with your community styling.

     

    Hope that helps, woodag!

    RickyS