Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Here is the code of custom style plugin.
<?php
// ...
function render() {
$sets = $this->render_grouping($this->view->result, $this->options['grouping']);
// Turn this all into an $options array for the jump menu.
$this->view->row_index = 0;
$fields = array();
foreach ($sets as $title => $records) {
foreach ($records as $row_index => $row) {
$this->view->row_index = $row_index;
// get_field - returns NULL if more than one grouping field selected
$fields[] = $this->get_field_value($this->view->row_index, $this->options['data_field']);
$this->view->row_index++;
}
}
unset($this->view->row_index);
return var_export($fields, TRUE);
}
// ...
?>
It uses views_plugin_style::get_field_value to get raw data from field, but prints error if more than one grouping field selected:
__clone method called on non-object in /var/d7/sites/project.22/modules/views/modules/field/views_handler_field_field.inc on line 650
Comments
Comment #1
elamanI've written quick hack, but still not sure if it could handle all situations.
Comment #2
tim.plunkettPlease read http://drupal.org/patch/create and upload your changes as a patch, then set to "needs review".
Comment #3
juhaniemi CreditAttribution: juhaniemi commentedI had kinda similar issue related to get_field_value(). If the field is empty, it ends up in the same PHP fatal error: __clone method called on non-object.
My display plugin needs to get the data directly, not through theme functions (the plugin outputs a custom JSON document). So this function is the ideal function to get the actual data by the field_name (names are not exactly the same ones in the $view->result row arrays).
Comment #4
MustangGB CreditAttribution: MustangGB commented