Find last item in template
I use Pods Temaplate for listing Pods items, but I did not find a way to find last item.
I can use $this->getTotalRows() for getting number of displayed Pods, but how to find the last one in the list?
Thank you for your help...
4 Answers
Try this:
<li
<?php if ( $this->row_number + 1 == $this->total ): ?>
class="last"
<?php endif; ?>
>Price:{@price}</li>
edited Feb 20 at 1:56
A query like this will return the record with the highest ID:
$pods->findRecords('t.id DESC', 1);
this->getTotalRows() will get the total number of items in your pod that match your query.
I am not sure if I understand. I use simple detail template:
<pre><li>Price: {@price}</li></pre>
But I would like to add special class to latest item in this template:
<pre><li class="last">Price: {@price}</li></pre>
And I do not know how to do it within pods template?
Thank you for your help...
edited Feb 17 at 1:50
Lovely, thank you very much!
I did not know about using $this->row_number and $this->total.
P. S. How can I highlight code as you? I tried code, pre and apostrophe, but nothing worked...
edited Feb 20 at 12:58


