You are here

function menu_position_edit_menu_link in Menu Position 6

Same name and namespace in other branches
  1. 7.2 menu_position.admin.inc \menu_position_edit_menu_link()
  2. 7 menu_position.admin.inc \menu_position_edit_menu_link()

Adds a menu position rule.

Parameters

$rid: ID of the rule needing a menu link.

$mlid: The mlid of the menu link used in the rule.

$plid: The mlid of the parent menu link specified in the rule.

$admin_title: The administrative title of the rule.

Return value

The mlid of the rule's new menu link.

2 calls to menu_position_edit_menu_link()
menu_position_add_menu_link in ./menu_position.admin.inc
Adds a menu position rule.
menu_position_edit_rule in ./menu_position.admin.inc
Edits a menu position rule.

File

./menu_position.admin.inc, line 540
Provides infrequently used functions and hooks for menu_position.

Code

function menu_position_edit_menu_link($rid, $mlid, $plid, $admin_title) {

  // Add a menu link to handle matching pages.
  $item = array(
    'link_path' => 'menu-position/' . $rid,
    'link_title' => $admin_title . ' (menu position rule)',
    'mlid' => $mlid,
    'plid' => $plid,
    'hidden' => 1,
    'module' => 'menu_position',
    'options' => array(
      'alter' => TRUE,
      'attributes' => array(
        'class' => 'menu-position-link',
      ),
    ),
  );

  // If this is an existing menu link, get the existing weight.
  if ($item['mlid']) {
    $existing_item = db_fetch_array(db_query("SELECT plid, weight FROM {menu_links} WHERE mlid = %d", $item['mlid']));
    $item['weight'] = $existing_item['plid'] == $plid ? $existing_item['weight'] : 0;
  }
  return menu_link_save($item);
}