You are here

function theme_sitemap_menu_link in Sitemap 8

Returns HTML for a menu link and submenu.

This is a one by one clone of the core theme_menu_link() function that allows custom theming of the sitemap page items.

Parameters

array $variables: An associative array containing:

  • element: Structured array data for a menu link.

Return value

string Returns html string for menu link.

1 string reference to 'theme_sitemap_menu_link'
sitemap_theme in ./sitemap.module
Implements hook_theme().

File

./sitemap.theme.inc, line 98
Sitemap theme functions.

Code

function theme_sitemap_menu_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';
  if ($element['#below']) {
    $sub_menu = \Drupal::service('renderer')
      ->render($element['#below']);
  }

  /** @var \Drupal\Core\Url $url */
  $url = $element['#url'];
  $url
    ->setOption('set_active_class', TRUE);
  $output = \Drupal::linkGenerator()
    ->generate($element['#title'], $url);
  return '<li' . new Attribute($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}