Find last item in template

0

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...

asked Feb 9 at 11:19

pavelevap

3

add comment
enter at least 15 characters

4 Answers

1

Try this:

<li
<?php if ( $this->row_number + 1 == $this->total ): ?>
class="last"
<?php endif; ?>
>Price:{@price}</li>

answered Feb 17 at 3:56

chris.pilko

889

edited Feb 20 at 1:56

add comment
enter at least 15 characters
0

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.

answered Feb 10 at 12:02

chris.pilko

889

add comment
enter at least 15 characters
0

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...

answered Feb 17 at 1:48

pavelevap

3

edited Feb 17 at 1:50

add comment
enter at least 15 characters
0

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...

answered Feb 20 at 12:57

pavelevap

3

edited Feb 20 at 12:58

It's [markdown](http://daringfireball.net/projects/markdown/). You can do it by clicking on that little button with "101010" on the toolbar or manually by leaving a blank line and then indenting your code by 5 or more spaces. – chris.pilko Feb 20 at 1:58
add comment
enter at least 15 characters