views_handler_field_counter.inc in Views (for Drupal 7) 6.3
File
handlers/views_handler_field_counter.inc
View source
<?php
class views_handler_field_counter extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
$options['counter_start'] = array(
'default' => 1,
);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['counter_start'] = array(
'#type' => 'textfield',
'#title' => t('Starting value'),
'#default_value' => $this->options['counter_start'],
'#description' => t('Specify the number the counter should start at.'),
'#size' => 2,
);
}
function query() {
}
function render($values) {
$count = is_numeric($this->options['counter_start']) ? $this->options['counter_start'] - 1 : 0;
$pager = $this->view->query->pager;
if ($pager
->use_pager()) {
$count += $pager
->get_items_per_page() * $pager
->get_current_page() + $pager
->get_offset();
}
$count += $this->view->row_index + 1;
return $count;
}
}