- πΊπΈUnited States markabur
I like this approach! In my case I needed to check which view I was currently altering, and I also needed some data from the rendered row result in order to use custom numbered markers. Here's what I changed:
- $context = array('view_row' => $result); + $context = array( + 'view_name' => $this->view->name, + 'view_display' => $this->view->current_display, + 'view_row' => $result, + 'view_row_rendered' => $this->rendered_fields[$id], + );
Here's how I am using the new context info. (My view is configured in Views UI with a result counter, which is available in view_row_rendered but not in view_row.)
function mymodule_geofield_map_data_alter($datum, $context) { if (!empty($context['view_row']) && $context['view_name'] == 'my_map') { $path = '/' . drupal_get_path('module', 'mymodule') . '/markers/'; // Path to custom numbered marker icon, e.g. mymodule/markers/number12.png . $result_counter = $context['view_row_rendered']['counter']; $icon = $path . 'number' . $result_counter . '.png'; // Set path to custom icon. $datum->options['icon'] = $icon; } }