开发者

Count rows in Drupal views plugin

开发者 https://www.devze.com 2022-12-29 13:52 出处:网络
I\'ve written myself a Drupal Views row plugin and I want to count the rows so I can do something with the output every Nth row.

I've written myself a Drupal Views row plugin and I want to count the rows so I can do something with the output every Nth row.

I can do this in the plugin's preprocessor function开发者_如何学编程 but if it gets used more than once (in panels for example) I can't reset the counter to zero.

Can someone point me in the right direction here?


The default style plugin for views adds a counter to the view object. It is available at

$view->row_index

If you are overwriting the render method in a custom style plugin remember to duplicate this functionality in your own render function.


You can have a look at the views_customfield module. (http://drupal.org/project/views_customfield) This module gives u access to row number in the view and also the option to add PHP code in each row. Pretty handy...

0

精彩评论

暂无评论...
验证码 换一张
取 消