arg

includes/path.inc, line 147

Versions
4.6 – 5
arg($index)
6 – 7
arg($index = NULL, $path = NULL)

Return a component of the current Drupal path.

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

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 explanation in menu.inc for how to construct callbacks that take arguments.

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).

Return value

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

▾ 71 functions call arg()

aggregator_form_category_submit in modules/aggregator/aggregator.module
Process aggregator_form_category form submissions. @todo Add delete confirmation dialog.
aggregator_form_feed_submit in modules/aggregator/aggregator.module
Process aggregator_form_feed form submissions. @todo Add delete confirmation dialog.
aggregator_menu in modules/aggregator/aggregator.module
Implementation of hook_menu().
aggregator_page_category in modules/aggregator/aggregator.module
Menu callback; displays all the items aggregated in a particular category.
aggregator_page_last in modules/aggregator/aggregator.module
Menu callback; displays the most recent items gathered from any feed.
aggregator_page_rss in modules/aggregator/aggregator.module
Menu callback; generate an RSS 0.92 feed of aggregator items or categories.
aggregator_page_source in modules/aggregator/aggregator.module
Menu callback; displays all the items captured from a particular feed.
block_admin_display in modules/block/block.module
Generate main block administration form.
blogapi_blogapi in modules/blogapi/blogapi.module
blog_link in modules/blog/blog.module
Implementation of hook_link().
book_admin_edit_submit in modules/book/book.module
book_block in modules/book/book.module
Implementation of hook_block().
book_form in modules/book/book.module
Implementation of hook_form().
book_help in modules/book/book.module
Implementation of hook_help().
book_menu in modules/book/book.module
Implementation of hook_menu().
color_form_alter in modules/color/color.module
Implementation of hook_form_alter().
color_scheme_form in modules/color/color.module
Form callback. Returns the configuration form.
comment_admin in modules/comment/comment.module
Menu callback; present an administrative comment listing.
comment_menu in modules/comment/comment.module
Implementation of hook_menu().
comment_node_url in modules/comment/comment.module
comment_render in modules/comment/comment.module
Renders comment(s).
contact_admin_delete_submit in modules/contact/contact.module
Process category delete form submission.
contact_admin_edit in modules/contact/contact.module
Category edit page.
contact_admin_edit_submit in modules/contact/contact.module
Process the contact category edit page form submission.
contact_mail_user_submit in modules/contact/contact.module
Process the personal contact page form submission.
contact_menu in modules/contact/contact.module
Implementation of hook_menu().
contact_user_page in modules/contact/contact.module
Personal contact page.
filter_admin_configure in modules/filter/filter.module
Menu callback; display settings defined by filters.
filter_admin_delete in modules/filter/filter.module
Menu callback; confirm deletion of a format.
filter_help in modules/filter/filter.module
Implementation of hook_help().
filter_menu in modules/filter/filter.module
Implementation of hook_menu().
filter_tips_long in modules/filter/filter.module
Menu callback; show a page with long filter tips.
forum_menu in modules/forum/forum.module
Implementation of hook_menu().
forum_prepare in modules/forum/forum.module
Implementation of hook_prepare; assign forum taxonomy when adding a topic from within a forum.
help_page in modules/help/help.module
Menu callback; prints a page listing general help for all modules.
legacy_menu in modules/legacy/legacy.module
Implementation of hook_menu().
locale_menu in modules/locale/locale.module
Implementation of hook_menu().
menu_get_active_help in includes/menu.inc
Returns the help associated with the active menu item.
node_form_alter in modules/node/node.module
Implementation of hook_form_alter().
node_help in modules/node/node.module
Implementation of hook_help().
node_menu in modules/node/node.module
Implementation of hook_menu().
node_revisions in modules/node/node.module
Menu callback for revisions related activities.
phptemplate_page in themes/engines/phptemplate/phptemplate.engine
Prepare the values passed to the theme_page function to be passed into a pluggable template engine. Uses the arg() function to generate a series of page template files suggestions based on the current path. If none are found, the default page.tpl.php...
poll_cancel in modules/poll/poll.module
Callback for canceling a vote
poll_menu in modules/poll/poll.module
Implementation of hook_menu().
poll_results in modules/poll/poll.module
Callback for the 'results' tab for polls you can vote on
poll_view in modules/poll/poll.module
Implementation of hook_view().
poll_vote in modules/poll/poll.module
Callback for processing a vote
poll_votes in modules/poll/poll.module
Callback for the 'votes' tab for polls you can see other votes on
profile_block in modules/profile/profile.module
Implementation of hook_block().
profile_browse in modules/profile/profile.module
Menu callback; display a list of user information.
profile_field_form in modules/profile/profile.module
Menu callback: Generate a form to add/edit a user profile field.
search_menu in modules/search/search.module
Implementation of hook_menu().
search_view in modules/search/search.module
Menu callback; presents the search form and/or search results.
statistics_exit in modules/statistics/statistics.module
Implementation of hook_exit().
statistics_menu in modules/statistics/statistics.module
Implementation of hook_menu().
statistics_node_tracker in modules/statistics/statistics.module
statistics_user_tracker in modules/statistics/statistics.module
system_help in modules/system/system.module
Implementation of hook_help().
system_menu in modules/system/system.module
Implementation of hook_menu().
taxonomy_menu in modules/taxonomy/taxonomy.module
Implementation of hook_menu().
theme_book_admin_table in modules/book/book.module
tracker_menu in modules/tracker/tracker.module
Implementation of hook_menu().
tracker_track_user in modules/tracker/tracker.module
Menu callback. Prints a listing of active nodes on the site.
user_admin_role in modules/user/user.module
Menu callback: administer roles.
user_block in modules/user/user.module
Implementation of hook_block().
user_edit in modules/user/user.module
user_menu in modules/user/user.module
Implementation of hook_menu().
user_user in modules/user/user.module
Implementation of hook_user().
watchdog_menu in modules/watchdog/watchdog.module
Implementation of hook_menu().
_user_edit_validate in modules/user/user.module

Code

<?php
function arg($index) {
  static $arguments, $q;

  if (empty($arguments) || $q != $_GET['q']) {
    $arguments = explode('/', $_GET['q']);
    $q = $_GET['q'];
  }

  if (isset($arguments[$index])) {
    return $arguments[$index];
  }
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.