menu_item_container.install in Menu item container 6
Same filename and directory in other branches
Provides enable/disable functions for menu item containers.
File
menu_item_container.installView source
<?php
/**
* @file
* Provides enable/disable functions for menu item containers.
*/
/**
* Implements hook_enable().
*/
function menu_item_container_enable() {
$result = db_query('SELECT mlid, options FROM {menu_links} WHERE options LIKE "%%s:22:\\"menu_item_container_id\\";%%"');
while ($row = db_fetch_array($result)) {
// Retrieve the container ID.
$options = unserialize($row['options']);
$link_path = 'menu-item-container/' . $options['menu_item_container_id'];
unset($options['menu_item_container_id']);
// Update the module, link_path, router_path, and external attributes.
db_query('UPDATE {menu_links} SET module = "menu_item_container", link_path = "%s", router_path = "menu-item-container", external = 0, options = "%s" WHERE mlid = %d', $link_path, serialize($options), $row['mlid']);
}
}
/**
* Implements hook_disable().
*/
function menu_item_container_disable() {
$result = db_query('SELECT mlid, link_path, options FROM {menu_links} WHERE module = "menu_item_container"');
while ($row = db_fetch_array($result)) {
// Save the container ID.
$options = unserialize($row['options']);
$options['menu_item_container_id'] = str_replace('menu-item-container/', '', $row['link_path']);
// Update the module, link_path, router_path, and external attributes.
db_query('UPDATE {menu_links} SET module = "menu", link_path = "<front>", router_path = "", external = 1, options = "%s" WHERE mlid = %d', serialize($options), $row['mlid']);
}
}
Functions
Name![]() |
Description |
---|---|
menu_item_container_disable | Implements hook_disable(). |
menu_item_container_enable | Implements hook_enable(). |