function references_dialog_plugin_display::render in References dialog 7
Render this display.
Overrides views_plugin_display::render
File
- views/
references_dialog_plugin_display.inc, line 202 - Contains the default display plugin.
Class
- references_dialog_plugin_display
- A plugin to handle defaults on a view.
Code
function render() {
$output = theme($this
->theme_functions(), array(
'view' => $this->view,
));
// Let's add the data necessary to javascript, so that we can
// act upon it there.
$js_result = array();
$entity_type = $this
->get_entity_type();
// The only safe way to determine the title of each item is to load the entities.
// We also need to know the specific
$entity_ids = array();
foreach ($this->view->result as $row => $result) {
$entity_ids[] = $result->{$this->view->base_field};
}
$entities = entity_load($entity_type, $entity_ids);
foreach ($this->view->result as $result) {
$js_result[] = array(
'entity_id' => $result->{$this->view->base_field},
'title' => entity_label($entity_type, $entities[$result->{$this->view->base_field}]),
'entity_type' => $entity_type,
);
}
drupal_add_js(drupal_get_path('module', 'references_dialog') . '/js/search-reference.js');
drupal_add_js(array(
'ReferencesDialog' => array(
'entities' => $js_result,
),
), 'setting');
return $output;
}