Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hi

I am trying to show a different message if the total amount of entries in a template, published between certain dates.
That's the code I am using:
Code: Select all
<cms:pages masterpage='contrats.php' start_on='2018-01-01' stop_before='2018-01-30' show_future_entries='1' limit="1">
<cms:show k_total_records />
<hr>
<cms:if k_total_records ge '1'>
It's one or greater than one!
<cms:else/>
It's less than one!
</cms:if>
</cms:pages>


It works if there's a least 1 entry matching the "start_on" and "stop_before" dates.
But the issue is when there's no entry. It will not display anything at all. Even "k_total_records" won't show a thing. I thought it would display "0", but it's not.

My code was made to display something if the "k_total_records" has at least 1 entry between the date range, then it should show something. If there's no entry, show something else.

What am I doing wrong here?
Thanks a lot!
Hi,

For the condition when no records are fetched, we should use <cms:no_results> e.g. as follows -
Code: Select all
<cms:pages ..>
   ...
   
   <cms:no_results>
      <h3>No pages found</h3>
   </cms:no_results>
</cms:pages>

Hope it helps.
Thanks a lot KK. Worked perfectly :)
Awesome support, as always.
You can delete this post ;)
4 posts Page 1 of 1
cron