Same name and namespace in other branches
  1. 4.6.x developer/hooks/core.php \hook_help()
  2. 4.7.x developer/hooks/core.php \hook_help()
  3. 5.x developer/hooks/core.php \hook_help()
  4. 6.x developer/hooks/core.php \hook_help()
  5. 7.x modules/system/system.api.php \hook_help()
  6. 8.9.x core/modules/help/help.api.php \hook_help()
  7. 9 core/modules/help/help.api.php \hook_help()

Provide online user help.

By implementing hook_help(), a module can make documentation available to the user for the module as a whole, or for specific pages. Help for developers should usually be provided via function header comments in the code, or in special API example files.

The page-specific help information provided by this hook appears in the Help block (provided by the core Help module), if the block is displayed on that page. The module overview help information is displayed by the Help module. It can be accessed from the page at /admin/help or from the Extend page. If a module implements hook_help() the help system expects module overview help to be provided.

For detailed usage examples of:

Parameters

string $route_name: For page-specific help, use the route name as identified in the module's routing.yml file. For module overview help, the route name will be in the form of "help.page.$modulename".

\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match. This can be used to generate different help output for different pages that share the same route.

Return value

string|array A render array, localized string, or object that can be rendered into a string, containing the help text.

Related topics

2 string references to 'hook_help'
hook_help_section_info_alter in core/modules/help/help.api.php
Perform alterations on help page section plugin definitions.
more_help_page_test_help_section_info_alter in core/modules/help/tests/modules/more_help_page_test/more_help_page_test.module
Implements hook_help_section_info_alter().
81 functions implement hook_help()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

action_help in core/modules/action/action.module
Implements hook_help().
announcements_feed_help in core/modules/announcements_feed/announcements_feed.module
Implements hook_help().
automated_cron_help in core/modules/automated_cron/automated_cron.module
Implements hook_help().
ban_help in core/modules/ban/ban.module
Implements hook_help().
basic_auth_help in core/modules/basic_auth/basic_auth.module
Implements hook_help().

... See full list

2 invocations of hook_help()
HelpController::helpPage in core/modules/help/src/Controller/HelpController.php
Prints a page listing general help for a module.
HelpEmptyPageTest::testEmptyHookHelp in core/modules/help/tests/src/Kernel/HelpEmptyPageTest.php
Ensures that no URL generator is called on a page without hook_help().

File

core/modules/help/help.api.php, line 71
Hooks for the Help system.

Code

function hook_help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match) {
  switch ($route_name) {

    // Main module help for the block module.
    case 'help.page.block':
      return '<p>' . t('Blocks are boxes of content rendered into an area, or region, of a web page. The default theme Olivero, for example, implements the regions "Sidebar", "Highlighted", "Content", "Header", "Footer Top", "Footer Bottom", etc., and a block may appear in any one of these areas. The <a href=":blocks">blocks administration page</a> provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions.', [
        ':blocks' => Url::fromRoute('block.admin_display')
          ->toString(),
      ]) . '</p>';

    // Help for another path in the block module.
    case 'block.admin_display':
      return '<p>' . t('This page provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the <em>Save blocks</em> button at the bottom of the page.') . '</p>';
  }
}