function menu_position_add_rule in Menu Position 7.2
Same name and namespace in other branches
- 6 menu_position.admin.inc \menu_position_add_rule()
- 7 menu_position.admin.inc \menu_position_add_rule()
Adds a menu position rule.
Parameters
$rule: An associate array defining the new rule to be created. Must contain the following keys:
- admin_title: The administrative title of the rule.
- conditions: An associative array whose keys are the machine names of the plugins actively configured in the rule. The value of each array element is array containing the necessary variables for that plugin.
- menu_name: The machine name of the menu where this rule is positioned.
- plid: The mlid of the parent menu link specified in the rule.
1 call to menu_position_add_rule()
- menu_position_rule_form_submit in ./
menu_position.admin.inc - Handles form submission for menu_position_rule_form().
File
- ./
menu_position.admin.inc, line 468 - Provides infrequently used functions and hooks for menu_position.
Code
function menu_position_add_rule($rule) {
$fields = array(
'admin_title' => $rule['admin_title'],
'conditions' => serialize($rule['conditions']),
'menu_name' => $rule['menu_name'],
'plid' => $rule['plid'],
);
$rid = db_insert('menu_position_rules')
->fields($fields)
->execute();
$mlid = menu_position_add_menu_link($rid, $rule['plid'], $rule['admin_title']);
// Now add the mlid back to the rule.
db_update('menu_position_rules')
->fields(array(
'mlid' => $mlid,
))
->condition('rid', $rid)
->execute();
}