To check in a smarty template if it was the last page of the page results

Here’s a method to check in a smarty template if it was the last page of page results.

{if $listings.current_page gte ($listings.total / $results_per_page)|ceil}
    True
{else}
    False
{/if}

where $listings.current_page is the current page user is on, $listings.total is the number of totals results and $results_per_page is the number of listings or rows that are displayed on each page. “gte” is >= operator and |ceil as the mathematical modifier which returns next lowest integer.

Leave a Reply