Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

Create the module help page on Drupal 8

By editor , 19 November, 2015
Question

How to create the module help page on Drupal 8 ?

Here an exemple : Module name : mymodule

function mymodule_help($route_name, RouteMatchInterface $route_match) {
  if ($route_name == 'help.page.mymodule') {
    $current_url = Url::fromRoute('<current>');
    if (strstr($current_url->toString(), '/admin/help/simple_analyse') === FALSE) {
      // Because system_modules() executes hook_help() for each module to 'test'
      // if they will return anything, but not actually display it, we want to
      // return a TRUE value if this is not actually the help page.
      return TRUE;
    }
    $output = '<dl>';
    $output .= '<dt>' . ('List of the currently available tokens on this site') . '</dt>';
    $token_tree = array(
      '#theme' => 'token_tree',
      '#token_types' => 'all',
      '#click_insert' => FALSE,
      '#show_restricted' => TRUE,
    );
    /** @var \Drupal\Core\Render\RendererInterface $renderer */
    $renderer = \Drupal::service('renderer');
    $output .= '<dd>' . $renderer->render($token_tree) . '</dd>';
    $output .= '</dl>';
    return $output;
  }
}

Tags

  • Drupal 8
  • Code

Comments

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer