Chris@0: '
',
Chris@0: '#weight' => 100,
Chris@0: ];
Chris@0: $variables['title_suffix']['shortcut_wrapper'] = [
Chris@0: '#markup' => '
',
Chris@0: '#weight' => -99,
Chris@0: ];
Chris@0: // Make sure the shortcut link is the first item in title_suffix.
Chris@0: $variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
Chris@0: }
Chris@0: }
Chris@0:
Chris@0: /**
Chris@0: * Implements hook_preprocess_HOOK() for maintenance-page.html.twig.
Chris@0: */
Chris@0: function bartik_preprocess_maintenance_page(&$variables) {
Chris@0: // By default, site_name is set to Drupal if no db connection is available
Chris@0: // or during site installation. Setting site_name to an empty string makes
Chris@0: // the site and update pages look cleaner.
Chris@0: // @see template_preprocess_maintenance_page
Chris@0: if (!$variables['db_is_active']) {
Chris@0: $variables['site_name'] = '';
Chris@0: }
Chris@0:
Chris@0: // Bartik has custom styling for the maintenance page.
Chris@0: $variables['#attached']['library'][] = 'bartik/maintenance_page';
Chris@0: }
Chris@0:
Chris@0: /**
Chris@0: * Implements hook_preprocess_HOOK() for node.html.twig.
Chris@0: */
Chris@0: function bartik_preprocess_node(&$variables) {
Chris@0: // Remove the "Add new comment" link on teasers or when the comment form is
Chris@0: // displayed on the page.
Chris@0: if ($variables['teaser'] || !empty($variables['content']['comments']['comment_form'])) {
Chris@0: unset($variables['content']['links']['comment']['#links']['comment-add']);
Chris@0: }
Chris@0: }
Chris@0:
Chris@0: /**
Chris@0: * Implements hook_preprocess_HOOK() for block.html.twig.
Chris@0: */
Chris@0: function bartik_preprocess_block(&$variables) {
Chris@0: // Add a clearfix class to system branding blocks.
Chris@0: if ($variables['plugin_id'] == 'system_branding_block') {
Chris@0: $variables['attributes']['class'][] = 'clearfix';
Chris@0: }
Chris@0: }
Chris@0:
Chris@0: /**
Chris@0: * Implements hook_preprocess_HOOK() for menu.html.twig.
Chris@0: */
Chris@0: function bartik_preprocess_menu(&$variables) {
Chris@0: $variables['attributes']['class'][] = 'clearfix';
Chris@0: }
Chris@0:
Chris@0: /**
Chris@0: * Implements hook_theme_suggestions_HOOK_alter() for form templates.
Chris@0: */
Chris@0: function bartik_theme_suggestions_form_alter(array &$suggestions, array $variables) {
Chris@0: if ($variables['element']['#form_id'] == 'search_block_form') {
Chris@0: $suggestions[] = 'form__search_block_form';
Chris@0: }
Chris@0: }
Chris@0:
Chris@0: /**
Chris@0: * Implements hook_form_alter() to add classes to the search form.
Chris@0: */
Chris@0: function bartik_form_alter(&$form, FormStateInterface $form_state, $form_id) {
Chris@0: if (in_array($form_id, ['search_block_form', 'search_form'])) {
Chris@0: $key = ($form_id == 'search_block_form') ? 'actions' : 'basic';
Chris@0: if (!isset($form[$key]['submit']['#attributes'])) {
Chris@0: $form[$key]['submit']['#attributes'] = new Attribute();
Chris@0: }
Chris@0: $form[$key]['submit']['#attributes']->addClass('search-form__submit');
Chris@0: }
Chris@0: }