May 21, 2014

hook_help() is the same as in D7

hook_help() in Drupal 8 has not changed and can be implemented in the .module file exactly as in D7.

The  .module  file is placed at the top-level directory of the module. In our case the location is

    modules/custom/optimizely/optimizely.module

Very abbreviated outline of D7 version, which I copied verbatim to D8:
function optimizely_help($path, $arg) {
  switch ($path) {

    case 'admin/help#optimizely':
      return t('...<a href="@settings">Optimizely...',
        array('@settings' => url('admin/config/system/optimizely/settings')));

    case 'admin/config/system/optimizely':
      return t('... A listing of the Optimizely ...');
    // Other cases ...
  }
}


Update for Drupal 8, alpha 13: hook_help() has a different signature and is no longer unchanged from Drupal 7. See http://optimizely-to-drupal-8.blogspot.com/2014/08/drupal-8-alpha11-alpha13.html


Source:

hook_help()
http://drupalcontrib.org/api/drupal/drupal!core!modules!help!help.api.php/function/hook_help/8

2 comments:

  1. I look forward to a review of the hook_help content. I always find that someone new to a project is the best person to review help/docs as they make no assumptions.

    ReplyDelete
    Replies
    1. I much agree that people who are new to a piece of software can provide fresh input as to the UX. So let's do this review sometime soon.

      Delete