You are here

function contextual_help in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/contextual/contextual.module \contextual_help()
  2. 7 modules/contextual/contextual.module \contextual_help()
  3. 9 core/modules/contextual/contextual.module \contextual_help()

Implements hook_help().

File

core/modules/contextual/contextual.module, line 75
Adds contextual links to perform actions related to elements on a page.

Code

function contextual_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.contextual':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('The Contextual links module gives users with the <em>Use contextual links</em> permission quick access to tasks associated with certain areas of pages on your site. For example, a menu displayed as a block has links to edit the menu and configure the block. For more information, see the <a href=":contextual">online documentation for the Contextual Links module</a>.', [
        ':contextual' => 'https://www.drupal.org/documentation/modules/contextual',
      ]) . '</p>';
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Displaying contextual links') . '</dt>';
      $output .= '<dd>';
      $output .= t('Contextual links for an area on a page are displayed using a contextual links button. There are two ways to make the contextual links button visible:');
      $output .= '<ol>';
      $sample_picture = [
        '#theme' => 'image',
        '#uri' => 'core/misc/icons/bebebe/pencil.svg',
        '#alt' => t('contextual links button'),
      ];
      $sample_picture = \Drupal::service('renderer')
        ->render($sample_picture);
      $output .= '<li>' . t('Hovering over the area of interest will temporarily make the contextual links button visible (which looks like a pencil in most themes, and is normally displayed in the upper right corner of the area). The icon typically looks like this: @picture', [
        '@picture' => $sample_picture,
      ]) . '</li>';
      $output .= '<li>' . t('If you have the <a href=":toolbar">Toolbar module</a> enabled, clicking the contextual links button in the toolbar (which looks like a pencil) will make all contextual links buttons on the page visible. Clicking this button again will toggle them to invisible.', [
        ':toolbar' => \Drupal::moduleHandler()
          ->moduleExists('toolbar') ? Url::fromRoute('help.page', [
          'name' => 'toolbar',
        ])
          ->toString() : '#',
      ]) . '</li>';
      $output .= '</ol>';
      $output .= t('Once the contextual links button for the area of interest is visible, click the button to display the links.');
      $output .= '</dd>';
      $output .= '</dl>';
      return $output;
  }
}