function npop_contextual_links_view_alter in Node pop-up 7
Implements hook_contextual_links_view_alter().
File
- ./
npop.module, line 450 - Create popup nodes with ajax and Drupal core functionality.
Code
function npop_contextual_links_view_alter(&$element, $items) {
if (empty($element['#element'])) {
return;
}
$contextual_element = $element['#element'];
// Change destinations for nodes with npop_ajax view_mode.
if (isset($contextual_element['#entity_type']) && $contextual_element['#entity_type'] == 'node' && $contextual_element['#view_mode'] == 'npop_ajax') {
if (!npop_check_change_url($contextual_element['#bundle'])) {
return;
}
foreach ($element['#links'] as &$link) {
if (!empty($link['query']['destination'])) {
// Set node url as destination.
$link['query']['destination'] = 'node/' . $contextual_element['#node']->nid;
}
}
}
}