Hi, I'm back with more custom view test results!
Following your suggestion at #1476066: Improve documentation for Map of View block, I got things going with the views style plugin.
But! I discovered that regular fields are named differently in the $view->row object if they are Field API fields.
Instead of $row->{$latitude} and $row->{$longitude}, they are $row->{'field_' . $latitude}[0]['raw']['value'] and $row->{'field_' . $longitude}[0]['raw']['value']. In other words, "field_" is prepended to their field name, (which already starts with field_ ). So in my case my fields named "field_reaction_lat" and "field_reaction_long" actually show up in $row as $row->field_field_reaction_lat[0]['raw']['value'].
Then, in the main $this->view where you are unsetting them from rendering, they don't have the field_ prefix, they are just field_reaction_lat and field_reaction_long - strange but true!
So... what the attached patch does is check and see if the {'field_' . $latitude}[0]['raw']['value'] version exists, and if so use the appropriate field names to get Lat/Long (which should work for Text/Integer etc field types). Then if those aren't found, it falls back to the original logic of $row->{$latitude}, so that it will continue to work as-is for ip_geoloc queries.
I also fixed a little bug where you were unsetting $this->view['latitude'] instead of $this->view[$latitude].
So using the attached, you can just output any view that has Latitude and Longitude as text fields, by setting their field names (field_whatever).
I don't have any ip_geoloc views set up (I don't actually have status module enabled) so the first thing to test would be that these changes haven't broken those... they shouldn't have I don't think.
I was looking around for a spot in the README.txt or anything that described the views output plugin but didn't see it.. I could help write some brief instructions for the two use cases (using a Relationship to get the ip_geoloc fields of node content, like the prepopulated report does, and using Text fields to supply the lag/long).
Comments
Comment #1
damien_vancouver commentedI added some more code to get myself all the way there, which also supports printing the field labels from the View. These labels support the label element, class, and colon options that can be set on each field. If "provide a label" isn't checked, the label isn't printed.
Lastly, I had to change the text in the Javascript that shows up on the balloon, from "Latest Visitor - You?" to just "Latest Visitor". (since it's never the viewer in my case).
Attached is revised patch with all this stuff for your perusal, and a screenshot of the end result for me, showing it all working on a view.
Comment #2
rdeboerThanks for this Damien!
Hope to find time to apply this soon.
Rik
Comment #3
rdeboerChecked in with creditation.
Thanks for the patch!