arg

Versions
mediamosa-21
arg($index = NULL, $path = NULL)

Return a component of the current Drupal path.

When viewing a page at the path "admin/structure/types", for example, arg(0) returns "admin", arg(1) returns "content", and arg(2) returns "types".

Avoid use of this function where possible, as resulting code is hard to read. In menu callback functions, attempt to use named arguments. See the explanation 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.

Parameters

$index The index of the component, where each component is separated by a '/' (forward-slash), and where the first component has an index of 0 (zero).

$path A path to break into components. Defaults to the path of the current page.

Return value

The component specified by $index, or NULL if the specified component was not found.

▾ 39 functions call arg()

aggregator_form_category_submit in modules/aggregator/aggregator.admin.inc
Process aggregator_form_category form submissions.
aggregator_form_feed_submit in modules/aggregator/aggregator.admin.inc
Process aggregator_form_feed() form submissions.
aggregator_page_category in modules/aggregator/aggregator.pages.inc
Menu callback; displays all the items aggregated in a particular category.
aggregator_page_last in modules/aggregator/aggregator.pages.inc
Menu callback; displays the most recent items gathered from any feed.
aggregator_page_rss in modules/aggregator/aggregator.pages.inc
Menu callback; generate an RSS 0.92 feed of aggregator items or categories.
aggregator_page_source in modules/aggregator/aggregator.pages.inc
Menu callback; displays all the items captured from a particular feed.
block_admin_display_form in modules/block/block.admin.inc
Generate main blocks administration form.
block_block_info_alter in modules/block/block.module
Implements hook_block_info_alter().
blog_node_view in modules/blog/blog.module
Implements hook_node_view().
comment_admin in modules/comment/comment.admin.inc
Menu callback; present an administrative comment listing.
dblog_init in modules/dblog/dblog.module
Implements hook_init().
devel_node_access_block_view in sites/all/modules/devel/devel_node_access.module
filter_tips_long in modules/filter/filter.pages.inc
Menu callback; show a page with long filter tips.
forum_form_alter in modules/forum/forum.module
Implements hook_form_alter().
hook_overlay_child_initialize in modules/overlay/overlay.api.php
Allow modules to act when an overlay child window is initialized.
mediamosa_batch_jobs_delete_confirm in sites/all/modules/mediamosa/modules/batch_jobs/mediamosa_batch_jobs.callbacks.inc
Callback function to display a confirmation form for deletion.
mediamosa_batch_jobs_log in sites/all/modules/mediamosa/modules/batch_jobs/mediamosa_batch_jobs.callbacks.inc
Callback function to display the contents of a log.
mediamosa_integrity_check_page in sites/all/modules/mediamosa/modules/integrity_check/mediamosa_integrity_check.module
Integrity check page / list.
mediamosa_integrity_check_start_submit in sites/all/modules/mediamosa/modules/integrity_check/mediamosa_integrity_check.module
Submit.
mediamosa_integrity_check_type_box in sites/all/modules/mediamosa/modules/integrity_check/mediamosa_integrity_check.module
Selectbox "typeBox".
mediamosa_server_form in sites/all/modules/mediamosa/core/node/mediamosa_node_mediamosa_server.inc
Implements hook_form().
menu_get_active_help in includes/menu.inc
Returns the help associated with the active menu item.
menu_get_item in includes/menu.inc
Get a router item.
menu_set_active_trail in includes/menu.inc
Sets or gets the active trail (path to root menu root) of the current page.
openid_test_yadis_xrds in modules/openid/tests/openid_test.module
Menu callback; XRDS document that references the OP Endpoint URL.
openid_user_add_submit in modules/openid/openid.pages.inc
profile_block_view in modules/profile/profile.module
Implements hook_block_view().
profile_field_form in modules/profile/profile.admin.inc
Menu callback: Generate a form to add/edit a user profile field.
statistics_exit in modules/statistics/statistics.module
Implements hook_exit().
statistics_node_tracker in modules/statistics/statistics.pages.inc
statistics_user_tracker in modules/statistics/statistics.pages.inc
system_init in modules/system/system.module
Implements hook_init().
template_preprocess_html in includes/theme.inc
Preprocess variables for html.tpl.php
template_preprocess_page in includes/theme.inc
Preprocess variables for page.tpl.php
template_preprocess_profile_wrapper in modules/profile/profile.module
Process variables for profile-wrapper.tpl.php.
update_help in modules/update/update.module
Implements hook_help().
user_admin_role in modules/user/user.admin.inc
Menu callback: administer roles.
user_block_view in modules/user/user.module
Implements hook_block_view().
_trigger_normalize_user_context in modules/trigger/trigger.module
Loads associated objects for user triggers.

Code

includes/path.inc, line 258

<?php
function arg($index = NULL, $path = NULL) {
  // Even though $arguments doesn't need to be resettable for any functional
  // reasons (the result of explode() does not depend on any run-time
  // information), it should be resettable anyway in case a module needs to
  // free up the memory used by it.
  // Use the advanced drupal_static() pattern, since this is called very often.
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['arguments'] = &drupal_static(__FUNCTION__);
  }
  $arguments = &$drupal_static_fast['arguments'];

  if (!isset($path)) {
    $path = $_GET['q'];
  }
  if (!isset($arguments[$path])) {
    $arguments[$path] = explode('/', $path);
  }
  if (!isset($index)) {
    return $arguments[$path];
  }
  if (isset($arguments[$path][$index])) {
    return $arguments[$path][$index];
  }
}
?>