Forum Discussion

prashanthkavya's avatar
7 years ago

show only floated messages from the message list

Hi,

 I want to find floated_messages for the post. i tried using the query for the same out not able to get through. I am also pasting the code that I have used.. Pls help. i am looping the message with featured content and want to show a message which are floated message and not floated messages . code is below. have removed the css part.

<div class="con_sec_o">
<ul>
<#assign x= rest("2.0","/search?q=" + "SELECT * FROM messages where labels.text= 'featured' ORDER BY post_time DESC LIMIT 4"?url) />
     <#list x.data.items as message1>
<li class="loop">
<div class="co_ar_o">
<img src=${asset.get("/html/assets/colored_arrow.jpg")} class="co_ar"/>
</div>
<div class="list_txt">
<span><a href="${message1.view_href}">${message1.subject}</a></span>
<p>by <span style="background-color:#ac208d; color:#fff; padding:0px 5px">Admin</span> <a href="${message1.author.view_href}" class="black_font">${message1.author.login}</a><p>
</div>
<div class="lc_sec">
<div class="l_o">
 
<img src=${asset.get("/html/assets/like_up.jpg")}/>
<span class="count_nmbr">
<#assign kudos_q= rest("2.0","/search?q=" + "${message1.kudos.query}"?url) />
${kudos_q.data.size}
</span>
</div>
<div class="c_o">
<img src=${asset.get("/html/assets/comment.jpg")}/>
<span class="count_nmbr">
<#assign replies_q= rest("2.0","/search?q=" + "${message1.replies.query}"?url) />
${replies_q.data.size} 
</span>
</div>
<div class="p_o">
<!-- SELECT+*+FROM+floated_messages+WHERE+message.id+%3D+%27message1.id%27+AND+scope%3D%27user%27 -->
<#assign float_topics_q= rest("2.0","/search?q=" + SELECT * FROM floated_messages WHERE message.id = '+ message1.id +' AND scope='user'?url) />
<!--  <#assign float_topics_q= rest("2.0","/search?q=" + "SELECT+*+FROM+floated_messages+WHERE+message.id+%3D+%27message1.id%27+AND+scope%3D%27user%27"?url) /> -->
<!-- ${float_topic_q.data.type} -->
</div>
</div>
</li>
</#list>
</ul>
</div>
  • Hi prashanthkavya,

    you missed the double quotes in floated_messages api and used plus symbols around message1.id . May below code will help.

     

    <ul>
    <#assign x= rest("2.0","/search?q=" + "SELECT * FROM messages where labels.text= 'featured' ORDER BY post_time DESC LIMIT 4"?url) />
    <#list x.data.items as message1>
    <li class="loop">
    <div class="list_txt">
    <span><a href="${message1.view_href}">${message1.subject}</a></span>
    <p>by <span style="background-color:#ac208d; color:#fff; padding:0px 5px">Admin</span> <a href="${message1.author.view_href}" class="black_font">${message1.author.login}</a></p>
    </div>
    <div class="lc_sec">
    <span class="count_nmbr">
    <#assign kudos_q= rest("2.0","/search?q=" + "${message1.kudos.query}"?url) />
    ${kudos_q.data.size}
    </span>
    </div>
    <div class="c_o">
    <span class="count_nmbr">
    <#assign replies_q= rest("2.0","/search?q=" + "${message1.replies.query}"?url) />
    ${replies_q.data.size}
    </span>
    </div>
    <div class="p_o">
    <#assign float_topics_q= rest("2.0","/search?q=" + "SELECT * FROM floated_messages WHERE message.id = '${message1.id}' AND scope='user'"?url) />
    <div>${float_topics_q.data.type}</div>
    <#list float_topics_q.data.items as float>
    <div>${float.subject},</div>
    </#list>
    </div>
    </li>
    </#list>
    </ul>

2 Replies

  • Hi prashanthkavya,

    you missed the double quotes in floated_messages api and used plus symbols around message1.id . May below code will help.

     

    <ul>
    <#assign x= rest("2.0","/search?q=" + "SELECT * FROM messages where labels.text= 'featured' ORDER BY post_time DESC LIMIT 4"?url) />
    <#list x.data.items as message1>
    <li class="loop">
    <div class="list_txt">
    <span><a href="${message1.view_href}">${message1.subject}</a></span>
    <p>by <span style="background-color:#ac208d; color:#fff; padding:0px 5px">Admin</span> <a href="${message1.author.view_href}" class="black_font">${message1.author.login}</a></p>
    </div>
    <div class="lc_sec">
    <span class="count_nmbr">
    <#assign kudos_q= rest("2.0","/search?q=" + "${message1.kudos.query}"?url) />
    ${kudos_q.data.size}
    </span>
    </div>
    <div class="c_o">
    <span class="count_nmbr">
    <#assign replies_q= rest("2.0","/search?q=" + "${message1.replies.query}"?url) />
    ${replies_q.data.size}
    </span>
    </div>
    <div class="p_o">
    <#assign float_topics_q= rest("2.0","/search?q=" + "SELECT * FROM floated_messages WHERE message.id = '${message1.id}' AND scope='user'"?url) />
    <div>${float_topics_q.data.type}</div>
    <#list float_topics_q.data.items as float>
    <div>${float.subject},</div>
    </#list>
    </div>
    </li>
    </#list>
    </ul>