Closed (works as designed)
Project:
Views PHP
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Nov 2011 at 18:29 UTC
Updated:
14 Jan 2015 at 08:40 UTC
Jump to comment: Most recent
Comments
Comment #1
chunty commentedI don't think this is an issue for this project as such - more one for the main views project - if you exclude the counter from the output its not available full stop - you can't even use it on your own theme template (which drove me crackers for ages!).
The simplest is to not exclude it then to use your own tpl file for the view row which does not display the counter.
Comment #2
bluetegu commentedHi,
The value of global counter is unavailable regardless if it's excluded or not. One can not extract the data in the output either (which is one of the workarounds for http://drupal.org/node/1140896).
I used the following workaround; in my view each row returned fields of a different node, which allowed me to deduce the row number from the nid by placing the following code in the output:
$key is 0 for first row, 1 for second etc., so echo $key+1 is same as printing the global counter.
Hope this will help someone
Comment #3
cattalk commentedSorry ,I cant get it to work. When I enter the above into the output field I get an Internal Server Error.
I tried to use the counter var in the PHP field by putting the counter into the "custom text" field. But this field also returns nothing in the PHP field array. Altough it's listed in the Avaliable Variables.
Thx
cat
Comment #4
bluetegu commentedHi Cat,
The above code works with php 5.3.0 and up (anonymous functions). If your php version is lower, replace:
with
In any case, make sure you add an echo command to have an actual output (like echo $key+1;).
Comment #5
cattalk commentedOk great! Thanks a lot bluetegu! Seems to work! I totally forgot that this server is running a lower PHP version.
Comment #6
cswan commentedThank you, bluetegu! Your post helped me. :)
Comment #7
shamsher_alam commentedThank for #2 its working fine for me....