Do not show the post if there is no post
Hi guys. I need some quick help. I have following code.
Requirement:
If There is no post then this div should not be visible in front end also same with View all Link:
<div class="clearfix two-latest-post">
<#assign messages = rest("2.0","/search?q=" + "SELECT * FROM messages WHERE author.id='${user.id}' ORDER BY post_time DESC LIMIT 5"?url) />
<#list messages.data.items as recent >
<#if recent>
<a href="${recent.view_href}">${recent.subject}</a><br/>
</#if>
</#list>
<br/>
<a href="abc.com"><strong>See more Recent Posts</strong></a>
</div>
bhupen - Below is the working code. You need to check the size of the result.
<#setting url_escaping_charset='ISO-8859-1'> <div class="clearfix two-latest-post"> <#assign messages = rest("2.0","/search?q=" + "SELECT * FROM messages WHERE author.id='${user.id}' ORDER BY post_time DESC LIMIT 5"?url) /> <#list messages.data.items as recent > <#if recent?has_content> <a href="${recent.view_href}">${recent.subject}</a><br/> </#if> </#list> <br/> <#if messages.data.size > 0> <!-- check the size of the response--> <a href="abc.com"><strong>See more Recent Posts</strong></a> </#if> </div>