- Patch #352712 by dmitrig01: better documentation for menu_get_object() and arg().
parent
634379299f
commit
eb0c7697c8
|
@ -727,11 +727,16 @@ function _menu_link_translate(&$item) {
|
||||||
/**
|
/**
|
||||||
* Get a loaded object from a router item.
|
* Get a loaded object from a router item.
|
||||||
*
|
*
|
||||||
* menu_get_object() will provide you the current node on paths like node/5,
|
* menu_get_object() provides access to objects loaded by the current router
|
||||||
* node/5/revisions/48 etc. menu_get_object('user') will give you the user
|
* item. For example, on the page node/%node, the router loads the %node object,
|
||||||
* account on user/5 etc. Note - this function should never be called within a
|
* and calling menu_get_object() will return that. Normally, it is necessary to
|
||||||
* _to_arg function (like user_current_to_arg()) since this may result in an
|
* specify the type of object referenced, however node is the default.
|
||||||
* infinite recursion.
|
* The following example tests to see whether the node being displayed is of the
|
||||||
|
* "story" content type:
|
||||||
|
* @code
|
||||||
|
* $node = menu_get_object();
|
||||||
|
* $story = $node->type == 'story';
|
||||||
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param $type
|
* @param $type
|
||||||
* Type of the object. These appear in hook_menu definitions as %type. Core
|
* Type of the object. These appear in hook_menu definitions as %type. Core
|
||||||
|
@ -739,8 +744,9 @@ function _menu_link_translate(&$item) {
|
||||||
* forum_term, menu, menu_link, node, taxonomy_vocabulary, user. See the
|
* forum_term, menu, menu_link, node, taxonomy_vocabulary, user. See the
|
||||||
* relevant {$type}_load function for more on each. Defaults to node.
|
* relevant {$type}_load function for more on each. Defaults to node.
|
||||||
* @param $position
|
* @param $position
|
||||||
* The expected position for $type object. For node/%node this is 1, for
|
* The position of the object in the path, where the first path segment is 0.
|
||||||
* comment/reply/%node this is 2. Defaults to 1.
|
* For node/%node, the position of %node is 1, but for comment/reply/%node,
|
||||||
|
* it's 2. Defaults to 1.
|
||||||
* @param $path
|
* @param $path
|
||||||
* See menu_get_item() for more on this. Defaults to the current path.
|
* See menu_get_item() for more on this. Defaults to the current path.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -148,12 +148,13 @@ function drupal_get_normal_path($path, $path_language = '') {
|
||||||
* Return a component of the current Drupal path.
|
* Return a component of the current Drupal path.
|
||||||
*
|
*
|
||||||
* When viewing a page at the path "admin/build/types", for example, arg(0)
|
* When viewing a page at the path "admin/build/types", for example, arg(0)
|
||||||
* would return "admin", arg(1) would return "content", and arg(2) would return
|
* returns "admin", arg(1) returns "content", and arg(2) returns "types".
|
||||||
* "types".
|
|
||||||
*
|
*
|
||||||
* Avoid use of this function where possible, as resulting code is hard to read.
|
* Avoid use of this function where possible, as resulting code is hard to read.
|
||||||
* Instead, attempt to use named arguments in menu callback functions. See the
|
* In menu callback functions, attempt to use named arguments. See the explanation
|
||||||
* explanation in menu.inc for how to construct callbacks that take arguments.
|
* in menu.inc for how to construct callbacks that take arguments. When attempting
|
||||||
|
* to use this function to load an element from the current path, e.g. loading the
|
||||||
|
* node on a node page, please use menu_get_object() instead.
|
||||||
*
|
*
|
||||||
* @param $index
|
* @param $index
|
||||||
* The index of the component, where each component is separated by a '/'
|
* The index of the component, where each component is separated by a '/'
|
||||||
|
|
Loading…
Reference in New Issue