You are here

function content_menu_preprocess_views_view_field in Content Menu 7

Same name and namespace in other branches
  1. 8 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 378
Main code for the content_menu.module.

Code

function content_menu_preprocess_views_view_field(&$vars) {
  $view =& $vars['view'];
  $field =& $vars['field'];
  $selection_view = explode(':', variable_get('content_menu_add_existing_content_view', 'menu_existing_content_selection'));
  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();
    if (!empty($item)) {
      $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),
      ));
    }
  }
}