You are here

function menu_firstchild_tokens_alter in Menu Firstchild 7

Implementation of hook_tokens_alter().

File

./menu_firstchild.module, line 103
menu_firstchild.module Main file for the menu_firstchild module.

Code

function menu_firstchild_tokens_alter(array &$replacements, array $context) {
  if (isset($replacements['[node:menu-link:parent:url:path]'])) {
    if (isset($context['data']['menu-link']) && $context['data']['menu-link']['link_path'] === '<firstchild>') {
      $parent = _menu_firstchild_find_non_firstchild_parent($context['data']['menu-link']);
      $replacements['[node:menu-link:parent:url:path]'] = drupal_get_path_alias($parent['link_path']);
    }
    if ($replacements['[node:menu-link:parent:url:path]'] === '<firstchild>') {
      $replacements['[node:menu-link:parent:url:path]'] = '';
    }
  }
}