You are here

function _menu_views_tokenize in Menu Views 7.2

Same name and namespace in other branches
  1. 8.3 menu_views.module \_menu_views_tokenize()

Helper function to tokenize a menu item view arguments and settings. Alters the menu view item array and the original values are replaced.

4 calls to _menu_views_tokenize()
menu_views_form_menu_overview_form_alter in ./menu_views.admin.inc
Implements hook_form_FORM_ID_alter().
menu_views_menu_breadcrumb_alter in ./menu_views.module
Implements hook_menu_breadcrumb_alter().
_menu_views_parents_recurse in ./menu_views.admin.inc
Recursive helper function for menu_parent_options().
_menu_views_replace_menu_item in ./menu_views.module

File

./menu_views.module, line 641
Module to allow Views to be attached as menu items.

Code

function _menu_views_tokenize(&$item) {
  if (isset($item['mlid']) && $item['mlid'] > 0) {
    $context['menu-link'] = menu_link_load($item['mlid']);
    $options = array(
      'callback' => '_menu_views_tokenize_callback',
    );
    if (isset($item['view']['arguments']) && !empty($item['view']['arguments'])) {
      $item['view']['arguments'] = token_replace($item['view']['arguments'], $context, array_merge($options, array(
        'urlencode' => TRUE,
        'clear' => TRUE,
      )));
    }
    $tokenizable_settings = array(
      'breadcrumb_title',
      'breadcrumb_path',
      'title_override',
    );
    if (isset($item['view']['settings'])) {
      foreach ($item['view']['settings'] as $key => $value) {
        if (in_array($key, $tokenizable_settings)) {
          $item['view']['settings'][$key] = token_replace($value, $context, $options);
        }
      }
    }
  }
}