1 entityreference_plugin_style.inc | entityreference_plugin_style::render() |
Render the display in this style.
Overrides views_plugin_style::render
File
- core/
modules/ entityreference/ views/ entityreference_plugin_style.inc, line 36 - Handler for entityreference_plugin_style.
Class
- entityreference_plugin_style
- @file Handler for entityreference_plugin_style.
Code
function render() {
$options = $this->display->handler->get_option('entityreference_options');
// Play nice with Views UI 'preview' : if the view is not executed through
// EntityReferenceSelectionHandlerViews::getReferencableEntities(), just
// display the HTML.
if (empty($options)) {
return parent::render();
}
// Group the rows according to the grouping field, if specified.
$sets = $this->render_grouping($this->view->result, $this->options['grouping']);
// Grab the alias of the 'id' field added by entityreference_plugin_display.
$id_field_alias = $this->display->handler->id_field_alias;
// @todo We don't display grouping info for now. Could be useful for select
// widget, though.
$results = array();
foreach ($sets as $records) {
foreach ($records as $index => $values) {
$this->view->row_index = $index;
// Sanitize html, remove line breaks and extra whitespace.
$results[$values->{$id_field_alias}] = filter_xss_admin(preg_replace('/\s\s+/', ' ', str_replace("\n", '', $this->row_plugin->render($values))));
}
}
unset($this->view->row_index);
return $results;
}