hook_help
- Drupal 5
- Drupal 6
developer/hooks/core.php, строка 823
- Версии
- 5
hook_help(
$section)- 6
hook_help($path, $arg)
Показывает контекстную справку для пользователей.
Вызывая hook_help()
, модуль делает доступной для ядра или других модулей справку. Вся пользовательская справка должна предоставляться с использованием этого хука; developer help should be provided with
Doxygen/api.module comments.
Детальный пример использования ищите в модуле page_example.module.
Параметры
$path
Путь в системе меню Drupal, для которого запрашивается справка, например,
admin/node или user/edit. If the router path includes a % wildcard,
then this will appear in the path - for example all node pages will
have the path node/% or node/%/view.
Also recognizes special descriptors after a '#'
sign. Some examples:
- admin/help#modulename The module's help text, displayed on the admin/help page and through the module's individual help link.
- user/help#modulename The help for a distributed authorization module (if applicable).
$arg
An array that corresponds to the return of the arg() function - if a module
needs to provide help for a page with additional parameters after the
Drupal path or help for a specific value for a wildcard in the path, then
the values in this array can be referenced. For example you could provide
help for user/1 by looking for the path user/% and $arg
[1] == '1'
. This
array should always be used rather than directly invoking arg(). Note that
depending on which module is invoking hook_help, $arg
may contain only,
empty strings. Regardless, $arg
[0] to $arg
[11] will always be set.
Возвращаемое значение
Локализованная (переведенная) строка, содержащая текст справки. Every web link, l()
, or
url()
must be replaced with %something and put into the final t()
call:
$output .= 'A role defines a group of users that have certain privileges as defined in %permission.'; $output = t($output, array('%permission' => l(t('user permissions'), 'admin/user/permission')));
Связанные темы
Код
<?php
function hook_help($path, $arg) {
switch ($path) {
case 'admin/help#block':
return '<p>'. t('Blocks are boxes of content that may be rendered into certain regions of your web pages, for example, into sidebars. Blocks are usually generated automatically by modules (e.g., Recent Forum Topics), but administrators can also define custom blocks.') .'</p>';
case 'admin/build/block':
return t('<p>Blocks are boxes of content that may be rendered into certain regions of your web pages, for example, into sidebars. They are usually generated automatically by modules, but administrators can create blocks manually.</p>
<p>If you want certain blocks to disable themselves temporarily during high server loads, check the "Throttle" box. You can configure the auto-throttle on the <a href="@throttle">throttle configuration page</a> after having enabled the throttle module.</p>
<p>You can configure the behaviour of each block (for example, specifying on which pages and for what users it will appear) by clicking the "configure" link for each block.</p>', array('@throttle' => url('admin/settings/throttle')));
}
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии