function views_handler_field_contextual_links::render
3.x views_handler_field_contextual_links.inc | views_handler_field_contextual_links::render($values) |
Render the contextual fields.
Overrides views_handler_field::render
File
- handlers/
views_handler_field_contextual_links.inc, line 56 - Definition of views_handler_field_contextual_links.
Class
- views_handler_field_contextual_links
- Provides a handler that adds contextual links.
Code
function render($values) {
$links = array();
foreach ($this->options['fields'] as $field) {
if (empty($this->view->style_plugin->rendered_fields[$this->view->row_index][$field])) {
continue;
}
$title = $this->view->field[$field]->last_render_text;
$path = '';
if (!empty($this->view->field[$field]->options['alter']['path'])) {
$path = $this->view->field[$field]->options['alter']['path'];
}
if (!empty($title) && !empty($path)) {
// Make sure that tokens are replaced for this paths as well.
$tokens = $this->get_render_tokens(array());
$path = strip_tags(decode_entities(strtr($path, $tokens)));
$links[$field] = array(
'href' => $path,
'title' => $title,
);
if (!empty($this->options['destination'])) {
$links[$field]['query'] = drupal_get_destination();
}
}
}
if (!empty($links)) {
$build = array(
'#prefix' => '<div class="contextual-links-wrapper">',
'#suffix' => '</div>',
'#theme' => 'links__contextual',
'#links' => $links,
'#attributes' => array('class' => array('contextual-links')),
'#attached' => array(
'library' => array(array('contextual', 'contextual-links')),
),
'#access' => user_access('access contextual links'),
);
return drupal_render($build);
}
else {
return '';
}
}