123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <?php
- use Drupal\Core\Url;
- function hook_toolbar() {
- $items = [];
-
-
- $items['global_search'] = [
- '#type' => 'toolbar_item',
- 'tab' => [
- '#type' => 'search',
- '#attributes' => [
- 'placeholder' => t('Search the site'),
- 'class' => ['search-global'],
- ],
- ],
- '#weight' => 200,
-
- '#attached' => [
- 'library' => [
- 'search/global',
- ],
- ],
- ];
-
-
- $items['home'] = [
- '#type' => 'toolbar_item',
- 'tab' => [
- '#type' => 'link',
- '#title' => t('Home'),
- '#url' => Url::fromRoute('<front>'),
- '#options' => [
- 'attributes' => [
- 'title' => t('Home page'),
- 'class' => ['toolbar-icon', 'toolbar-icon-home'],
- ],
- ],
- ],
- '#weight' => -20,
- ];
-
-
-
-
-
-
-
-
- $items['commerce'] = [
- '#type' => 'toolbar_item',
- 'tab' => [
- '#type' => 'link',
- '#title' => t('Shopping cart'),
- '#url' => Url::fromRoute('cart'),
- '#options' => [
- 'attributes' => [
- 'title' => t('Shopping cart'),
- ],
- ],
- ],
- 'tray' => [
- '#heading' => t('Shopping cart actions'),
- 'shopping_cart' => [
- '#theme' => 'item_list',
- '#items' => [],
- ],
- ],
- '#weight' => 150,
- ];
-
-
-
-
-
-
-
-
- $items['user_messages'] = [
-
-
- '#type' => 'toolbar_item',
- 'tab' => [
- '#type' => 'link',
- '#theme' => 'user_message_toolbar_tab',
- '#theme_wrappers' => [],
- '#title' => t('Messages'),
- '#url' => Url::fromRoute('user.message'),
- '#options' => [
- 'attributes' => [
- 'title' => t('Messages'),
- ],
- ],
- ],
- 'tray' => [
- '#heading' => t('User messages'),
- 'messages' => [],
- ],
- '#weight' => 125,
- ];
- return $items;
- }
- function hook_toolbar_alter(&$items) {
-
- $items['commerce']['#weight'] = 5;
- }
|