What code do I use to get it to show row numbers?

Comments

joshg’s picture

Add field--custom field
Put the code in the box or you can put the code in the header or footer box within the view setup.

print $GLOBALS['current_view']->num_rows;

see http://drupal.org/node/131031 for more Details on this topic.

jfha73’s picture

I tried but all I could see was the total row number for the view, but what I need is to show something like this:

Row Number|Description
1. |Record 1
2. |Record 2

etc.

I also checked the link you sent me, but I did not see anything that tells me how to do it.

casey’s picture

echo ++$static .".";

Or if you use $static in other custom fields

echo ++$static['mycounter'] .".";
jfha73’s picture

OK, that worked for the first page only, when I jump to any other page it counts from the beginning again, or in other words in each page I get 1,2,3,4,5,etc not the continuation of the page before.

casey’s picture

Try this:

global $pager_page_array, $current_view;
echo (++$static['rownumber'] + ($pager_page_array[0] * $current_view->pager_limit)) .".";
jfha73’s picture

Status: Active » Fixed

Perfect, that worked.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.