Full ELMS Learning Network documentation
function menu_get_object
Error message
User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).cis7 menu.inc | menu_get_object($type = 'node', $position = 1, $path = NULL) |
cle7 menu.inc | menu_get_object($type = 'node', $position = 1, $path = NULL) |
elmsmedia7 menu.inc | menu_get_object($type = 'node', $position = 1, $path = NULL) |
icor7 menu.inc | menu_get_object($type = 'node', $position = 1, $path = NULL) |
meedjum_blog7 menu.inc | menu_get_object($type = 'node', $position = 1, $path = NULL) |
mooc7 menu.inc | menu_get_object($type = 'node', $position = 1, $path = NULL) |
Gets a loaded object from a router item.
menu_get_object() provides access to objects loaded by the current router item. For example, on the page node/%node, the router loads the %node object, and calling menu_get_object() will return that. Normally, it is necessary to specify the type of object referenced, however node is the default. The following example tests to see whether the node being displayed is of the "story" content type:
$node = menu_get_object();
$story = $node->type == 'story';
Parameters
$type: Type of the object. These appear in hook_menu definitions as %type. Core provides aggregator_feed, aggregator_category, contact, filter_format, forum_term, menu, menu_link, node, taxonomy_vocabulary, user. See the relevant {$type}_load function for more on each. Defaults to node.
$position: The position of the object in the path, where the first path segment is 0. For node/%node, the position of %node is 1, but for comment/reply/%node, it's 2. Defaults to 1.
$path: See menu_get_item() for more on this. Defaults to the current path.
Related topics
- book_block_view in modules/
book/ book.module - Implements hook_block_view().
- book_page_alter in modules/
book/ book.module - Implements hook_page_alter().
- book_touch_thumbnav_widget in sites/
all/ modules/ elmsln_contrib/ book_touch/ book_touch.module - Implements hook_thumbnav_widget().
- cis_helper_page_build in profiles/
cis/ modules/ custom/ cis_helper/ cis_helper.module - Implements hook_page_build().
- cis_service_connection_block_section_outline in sites/
all/ modules/ elmsln_contrib/ cis_connector/ modules/ cis_service_connection/ cis_service_connection.module - Render a block based on section context
File
- includes/
menu.inc, line 971 - API for the Drupal menu system.
Code
function menu_get_object($type = 'node', $position = 1, $path = NULL) {
$router_item = menu_get_item($path);
if (isset($router_item['load_functions'][$position]) && !empty($router_item['map'][$position]) && $router_item['load_functions'][$position] == $type . '_load') {
return $router_item['map'][$position];
}
}