Hi all,

I have View which displays a series of teasers. It would be useful (nay, essential :-) ) for me to be able to know the Order of these teasers, i.e. which place they occupy in the series. Hmm, that sounds like gibberish. OK, this is the situation. At this moment, I display:

Teaser yadda-yadda
Teaser more-yadda-yadda
Teaser still-more-yadda-yadda
...
Teaser more-gibberish
...
Teaser sigh-still-more-yadda-yadda

I would like to be able to manipulate the "rank number" in my node-mycontenttype.tpl.php), so:

1. Teaser yadda-yadda
2. Teaser more-yadda-yadda
3. Teaser still-more-yadda-yadda
...
8. Teaser more-gibberish
...
17. Teaser sigh-still-more-yadda-yadda

How can I, for instance, know in node-mycontenttype.tpl.php that Teaser nr. 8 or 17 or whatever other number is being rendered/displayed? This would greatly help me in adding some variation in the (rather dull) display of series of teasers.

All help is welcome!

Ludo

Comments

brenda003’s picture

My first thought, and probably the easiest solution, is to switch to a list view, change the CSS for that list to be list-style-type: decimal, and you could style it to appear like a teaser view if you wanted.

modul’s picture

Hi Brenda,

Thanks for your suggestion. In the meantime, I found out that there is a variable $id at my disposal in node-mycontenttype.tpl.php, and that allows me to, for instance, "highlight" teaser nr. 17. $id runs from 1 incrementally up to the last teaser being shown.

Another variable which I "discovered", is $zebra, which is either odd or even. Accordingly, you can style your teasers.

I just happened to stumble upon these $id and $zebra variables after running get_defined_vars(), which shows you all variables set by the system or declared by the user:

print_r(get_defined_vars());

Come to think of it: is there a list of these variables somewhere on this forum, a list of available variables in situation a) or situation b), and with some explanation of what they contain? I feel that would be very useful!!

Ludo