Active
Project:
Views Custom Field
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
24 Oct 2011 at 16:10 UTC
Updated:
26 Oct 2011 at 13:34 UTC
I've added a rownumber field to a view and the number produced is as expected for standard display styles (e.g. unformatted, list, table).
However, when used as in an OpenLayers Label, the values are rownumber + total number of rows, e.g. in a list they're "1,2,3", but in the OpenLayers map they're "4,5,6".
I think this is due to OpenLayers init-ing the handler once, but somehow iterating over it twice for the same record (ref: $this->rownumbers in views_customfield/includes/views_customfield_handler_field_rownumber.inc)
I'm not sue if the problem is with OpenLayers or Views Custom Field (or even just my config) but, whilst I investigate further, I'm posting here:
Comments
Comment #1
Dave-B commentedBy adding some echo statements I've found that calls to advanced_render() [0] from theme_views_view_field() [1] have correct rownumbers, but subsequent calls to advanced_render() by map_features() [2] add rownumber the the total last rownumber produced by theme_views_view_field()
I presume that the rownumbers property should be reset after theme_views_view_field() has finished with it...
[0] advanced_render() in sites/all/modules/views/handlers/views_handler_field.inc
[1] theme_views_view_field() in sites/all/modules/views/theme/theme.inc
[2] map_features() in sites/all/modules/openlayers/modules/openlayers_views/views/openlayers_views_style_data.inc
Comment #2
Dave-B commentedI've got the result I want, by reseting the rownumbers variable in the render() function of views_customfield/includes/views_customfield_handler_field_rownumber.inc, from:
...to:
(Of course, I probably ought to put that in a custom module, rather than editing the VCF code.)
This is a total hack, as I can't fathom how/where/why the render() code is being called in different ways, so it uses the details of the specific field I'm interested in.