Basic PHP question for Drupal Views theming
Posted
by oalo
on Stack Overflow
See other posts from Stack Overflow
or by oalo
Published on 2010-05-13T17:26:47Z
Indexed on
2010/05/13
18:14 UTC
Read the original article
Hit count: 269
My PHP and programming knowledge is extremely basic, so this is probably a dumb question:
I am theming a View in Drupal 6, and I want to add an id with a consecutive number to each item in the view (first item would have the id #item1, the second #item2, etc).
I am customizing the style output (views-view-unformatted--MYVIEWNAME.tpl.php) and the row style output (views-view-fields--MYVIEWNAME.tpl.php), and I want to add a counter variable in the foreach loop in the style output tpl, and then use that variable in the row style output tpl, but the last one is not recognizing the variable. It does not give me any errors, but doesnt print the number.
I understand this has probably something to do with variables visibility, how can I declare the counter variable in the style .tpl so I can the use it in the row style .tpl?
Thank you
© Stack Overflow or respective owner