Forum Discussion

skylinegtr's avatar
10 years ago

Need help with calling two API

How can I call two API in one custom component box? I want to display posts from the Forums and Knowledge Base. My code is below. Please help.   <li style="height: 342px;" class="tile"> <div class...
  • OlivierS's avatar
    10 years ago

    skylinegtr try the code below but in the SELECT statement replace 'travellers' and 'ULTRA board Knowledge base' with your board and knowledgebase

     

    <li style="height: 342px;" class="tile">
      <div class="border"><h2 class="tile-title">Freatured Post</h2></div>
      <div class="inner">  
        <#attempt>
          <#assign messages = rest("2.0","/search?q=" + "SELECT subject, view_href, post_time_friendly, board.id, teaser, author  FROM messages WHERE board.id IN('travellers', 'ULTRA board Knowledge Base') ORDER BY post_time DESC LIMIT 10"?url) />
          <#recover>
        </#attempt>
        
        <#if messages.message?size gt 0>
          <div class="custom-recent-articles-container">
            <div class="custom-recent-articles-heading-bar"><span class="custom-recent-articles-heading-bar-title">${text.format("")}</span></div>    
    
            <#list messages.data.items as message > 
              <#assign posted_by_userid = message.author.login?string />
              <#assign posted_by_label = text.format("Posted By:") />
        
              <div class="custom-recent-article-wrapper">
                <div class="custom-article-header">
                  <div class="custom-article-subject"><a href="${message.view_href}">${message.subject}</a></div>
                  <div class="custom-article-posted-by">
                    <span class="author">${posted_by_label} <#if ((posted_by_userid != "") && (posted_by_userid != "Anonymous"))><@component id="common.widget.user-name" user="conv:${message.author.login}" /></#if></span>
                  </div>
                </div>
                <div class="custom-article-teaser">
                  <#if message.teaser?length gt 0>
                    ${message.teaser} <span class="custom-read-more"><a href="${message.@view_href}">${text.format("")}</a></span>
                  </#if>
                </div>
              </div>
            </#list>
          </#if>
        </div>
      </div>
    </li>