Тебя еще не убедили эти надписи? Присоединяйся к нам, вместе мы все здесь переведем!
includes/path.inc, строка 159
- 5
arg($index)
- 6
arg($index = NULL, $path = NULL)
Возвращает составные части текущего адреса страницы.
Когда открыта страница с путем "admin/content/types"
, arg(0) будет возвращать "admin"
, arg(1) будет возвращать "content"
, и arg(2) возвратит "types"
.
Избегайте использования этой функции по возможности, так как при ее применении код становится неуниверсальным и мало-читабельным. Вместо этого, используйте коллбэки меню, которые позволяют передавать части текущего адреса как аргументы функции этого коллбэка.
Примечание: Функция работает с внутренним путем друпала, а не с конечным адресом, поэтому если вы находитесь на странице "blog/some-post"
, а ее настоящим адресом является "node/123"
, то arg(1) будет равен "123"
, а не "some-post"
.
Параметры
$index
Индекс части адреса, где каждая часть разделена слешом ('/'
), и где первая часть имеет индекс 0 (ноль).
$path
(опционально) Путь, который следует разбить. Если не указан, используется текущий внутренний адрес.
Возвращаемое значение
Часть адреса с индексоми $index
, или FALSE
, если часть не найдена.
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 NULL if the specified component was
not found.
▸ 34 функции вызывают arg()
▾ 34 функции вызывают 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
- Коллбэк меню. Генерирует фид из материалов аггергатора или категорий в формате RSS 0.92.
- 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.
- blog_link in modules/blog/blog.module
- Реализация hook_link().
- color_form_alter in modules/color/color.module
- Реализация hook_form_alter().
- color_scheme_form in modules/color/color.module
- Конструктор формы. Возвращает форму конфигурирования.
- comment_admin in modules/comment/comment.admin.inc
- Коллбэк меню; отображает список комментариев для администрирования.
- comment_node_url in modules/comment/comment.module
- Возвращает нулевой и первый компоненты пути, разделенные слэшем.
- comment_render in modules/comment/comment.module
- Отображает комментарии.
- dblog_init in modules/dblog/dblog.module
- filter_admin_delete in modules/filter/filter.admin.inc
- Menu callback; confirm deletion of a format.
See alsofilter_admin_delete_submit()
- filter_tips_long in modules/filter/filter.pages.inc
- Menu callback; show a page with long filter tips.
- forum_nodeapi in modules/forum/forum.module
- Implementation of hook_nodeapi().
- menu_get_active_help in includes/menu.inc
- Возвращает справку связанную с активизированным пунктом меню.
- menu_get_item in includes/menu.inc
- Получает элемент роутера.
- menu_local_tasks in includes/menu.inc
- Собирает локальные задачи (вкладки) для заданного уровня.
- menu_set_active_trail in includes/menu.inc
- Задает (или получает) активный след текущей страницы - путь к корню в дереве меню.
- openid_user_add_validate in modules/openid/openid.pages.inc
- profile_block in modules/profile/profile.module
- Реализация hook_block().
- profile_field_form in modules/profile/profile.admin.inc
- Menu callback: Generate a form to add/edit a user profile field.
See alsoprofile_field_form_validate()
- statistics_exit in modules/statistics/statistics.module
- Implementation of 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
- Реализация hook_init().
- template_preprocess_page in includes/theme.inc
- Обрабатывает переменные для 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
- Реализация hook_help().
- user_admin_role in modules/user/user.admin.inc
- Menu callback: administer roles.
See alsouser_admin_role_validate()
- user_block in modules/user/user.module
- Реализация hook_block().
- _trigger_normalize_user_context in modules/trigger/trigger.module
- When an action is called in a context that does not match its type,
the object that the action expects must be retrieved. For example, when
an action that works on nodes is called during the user hook, the
node object is not available since the user...
Код
<?php
function arg($index = NULL, $path = NULL) {
static $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];
}
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии