DEV Community

Filimonov
Filimonov

Posted on

Create a Help page for a module in Drupal 8

First, I'll create a test module to have somewhere to show it:

drush generate module
Enter fullscreen mode Exit fullscreen mode

I call it the tester helper

I write "no" everywhere, because only the  raw `.module` endraw  file will be needed.

Open the .module file and use the following template:

<?php

use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function tester_helper_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.tester_helper':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('The module is example:') . '</p';
      $output .= '<ul>';
      $output .= '<li>' . t('To show simple hook template') . '</li>';
      $output .= '<li>' . t('To show how the page looks like') . '</li>';
      $output .= '<li>' . t('To show it is very easy to create help page for module') . '</li>';
      $output .= '</ul>';
      return $output;

    default:
  }
}
Enter fullscreen mode Exit fullscreen mode

Change tester_helper to the machine name of your module.
In the variable $output write the contents of the page help.


This is what this page looks like for me:

Image description

Top comments (0)