Forum Discussion

bhupen's avatar
bhupen
Advisor
10 years ago
Solved

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 t...
  • VarunGrazitti's avatar
    10 years ago

    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 &gt; 0> <!-- check the size of the response-->
    		<a href="abc.com"><strong>See more Recent Posts</strong></a>
    	</#if>
    </div>