menu_node_edit_token_values

Versions
menu_node_edit
menu_node_edit_token_values($type, $object = NULL, $options = array())

Implement hook_token_values().

Provides tokens for the path alias of a menu parent.

Code

./menu_node_edit.module, line 897

<?php
function menu_node_edit_token_values($type, $object = NULL, $options = array()) {
  if (!menu_node_edit_tokens() || $type != 'node') {
    return;
  }
  // Set a default value.
  $value = t('content');
  if (!empty($object->nid)) {
    $path = "node/$object->nid";
    $plid = db_result(db_query("SELECT ml.plid FROM {menu_links} ml INNER JOIN {menu_custom} mc ON ml.menu_name = mc.menu_name WHERE ml.link_path = '%s'", $path));
  }
  if (!empty($plid)) {
    $result = db_result(db_query("SELECT u.dst FROM {url_alias} u INNER JOIN {menu_links} ml ON ml.link_path = u.src WHERE ml.mlid = %d", $plid));
  }
  if (!empty($result)) {
    $value = $result;
  }

  $tokens = array();
  $tokens['menu-parent-path-alias'] = check_plain($value);
  $tokens['menu-parent-path-alias-path'] = $value;
  return $tokens;
}
?>

Contact

  • agentrickard [at] gmail [dot] com

Donations

My Amazon.com Wish List