You are here

function content_menu_preprocess_views_view_field in Content Menu 8

Same name and namespace in other branches
  1. 7 content_menu.module \content_menu_preprocess_views_view_field()

Implements template_preprocess_views_view_field().

For views to select exiting content, rewrite the nid field ("select" link) to link to the correct target url and pass through the querystring params.

File

./content_menu.module, line 315

Code

function content_menu_preprocess_views_view_field(&$vars) {
  $view =& $vars['view'];
  $field =& $vars['field'];
  $selection_view = explode(':', config('content_menu.settings')
    ->get('add_existing_content_view'));
  if ($field->field == 'nid' && $view->name == $selection_view[0] && (!isset($selection_view[1]) || $view->current_display == $selection_view[1])) {
    module_load_include('inc', 'content_menu', 'content_menu.menu_admin');
    $item = content_menu_get_menu_item_from_querystring();
    $item['link_path'] = 'node/' . $field->original_value;
    $url = 'admin/structure/menu/manage/' . $item['name'] . '/add';
    $vars['output'] = l(t('select'), $url, array(
      'query' => content_menu_assemble_query_string($item),
    ));
  }
}