web:drupal:theme:menu-icons
Dies ist eine alte Version des Dokuments!
Menu-Icons
- templatename.theme
/** fuer menu_attributes: * svg icons als svg sprite bereitstellen * passendes sprite auswaehlen */ use Drupal\Component\Render\FormattableMarkup; /** * Implements theme_preprocess_menu(). */ function swiftly_preprocess_menu(&$variables, $hook) { foreach ($variables['items'] as &$item) { $attributes = $item['url']->getOption('attributes'); if (isset($attributes['data-icon'])) { $title = new FormattableMarkup(' <div class="flex gap-1 items-center"> <svg class="icon @icon w-8 hover:fill-onyx" viewbox="0 0 24 24"><use xlink:href="#@icon"></use></svg> <span class="hidden md:block">@title</span> </div> ', [ '@title' => $item['title'], '@icon' => $attributes['data-icon'], ]); $item['title'] = $title; } } }
web/drupal/theme/menu-icons.1663160224.txt.gz · Zuletzt geändert: 2022/09/14 12:57 von phoenixseo