0

enter image description here

I created a custom module and how to add a link along with icon. Basically, I want to add notification icon

backlinks_notifications.index:
  title: 'Notifications'
  parent: system.admin_config_ui (whats the name of that blad navigation bar on top.)
  description: 'Notificationsx'
  url: internal:/home

FYI : Its Admin theme.

2
   /**
    * Implements hook_toolbar().
    */
    function backlinks_notifications_toolbar() {
        $items = [];
        $items['toolbar_menu_backlinks_notifications'] = [
            '#type' => 'toolbar_item',
            'tab' => [
                '#type' => 'link',
                '#title' => 'Notifications',
                '#url' =>  Url::fromRoute('<front>'),
                '#options' => [
                    'attributes' => array(
                        'title' => t('Backlinks Notification'),
                        'class' => array(
                        'toolbar-item',
                        'toolbar-icon',
                        'toolbar-icon-backlinks-notifications',
                        ),
                    ),
                ],
            ],
            '#weight' => 999,
            '#attached' => array(
                'library' => array(
                    'backlinks_notifications/backlinks_notifications',
                ),
            ),
        ];
        return $items;
    }

Hook available at https://api.drupal.org/api/drupal/core%21modules%21toolbar%21toolbar.api.php/function/hook_toolbar/8.2.x

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.