getFileUri(); $image_path = file_create_url($uri); } else { $image_path = THEME_PATH . "/images/slide-{$i}.jpg"; } $vars['slider'][] = array( 'url' => theme_get_setting("slide_url_{$i}", "bartik"), 'src' => $image_path, 'title' => theme_get_setting("slide_title_{$i}", "bartik"), ); } } } /** * Implements hook_preprocess_HOOK() for page templates. */ function bartik_preprocess_page_title(&$variables) { // Since the title and the shortcut link are both block level elements, // positioning them next to each other is much simpler with a wrapper div. if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) { // Add a wrapper div using the title_prefix and title_suffix render // elements. $variables['title_prefix']['shortcut_wrapper'] = [ '#markup' => '
', '#weight' => 100, ]; $variables['title_suffix']['shortcut_wrapper'] = [ '#markup' => '
', '#weight' => -99, ]; // Make sure the shortcut link is the first item in title_suffix. $variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100; } } /** * Implements hook_preprocess_HOOK() for maintenance-page.html.twig. */ function bartik_preprocess_maintenance_page(&$variables) { // By default, site_name is set to Drupal if no db connection is available // or during site installation. Setting site_name to an empty string makes // the site and update pages look cleaner. // @see template_preprocess_maintenance_page if (!$variables['db_is_active']) { $variables['site_name'] = ''; } // Bartik has custom styling for the maintenance page. $variables['#attached']['library'][] = 'bartik/maintenance_page'; } /** * Implements hook_preprocess_HOOK() for node.html.twig. */ function bartik_preprocess_node(&$variables) { // Remove the "Add new comment" link on teasers or when the comment form is // displayed on the page. if ($variables['teaser'] || !empty($variables['content']['comments']['comment_form'])) { unset($variables['content']['links']['comment']['#links']['comment-add']); } } /** * Implements hook_preprocess_HOOK() for block.html.twig. */ function bartik_preprocess_block(&$variables) { // Add a clearfix class to system branding blocks. if ($variables['plugin_id'] == 'system_branding_block') { $variables['attributes']['class'][] = 'clearfix'; } } /** * Implements hook_preprocess_HOOK() for menu.html.twig. */ function bartik_preprocess_menu(&$variables) { $variables['attributes']['class'][] = 'clearfix'; } /** * Implements hook_theme_suggestions_HOOK_alter() for form templates. */ function bartik_theme_suggestions_form_alter(array &$suggestions, array $variables) { if ($variables['element']['#form_id'] == 'search_block_form') { $suggestions[] = 'form__search_block_form'; } } /** * Implements hook_form_alter() to add classes to the search form. */ function bartik_form_alter(&$form, FormStateInterface $form_state, $form_id) { if (in_array($form_id, ['search_block_form', 'search_form'])) { $key = ($form_id == 'search_block_form') ? 'actions' : 'basic'; if (!isset($form[$key]['submit']['#attributes'])) { $form[$key]['submit']['#attributes'] = new Attribute(); } $form[$key]['submit']['#attributes']->addClass('search-form__submit'); } } function bartik_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) { $form['busi_settings'] = array( '#type' => 'details', '#title' => t('Business Settings'), '#collapsible' => FALSE, '#collapsed' => FALSE, ); $form['busi_settings']['slideshow'] = array( '#type' => 'details', '#title' => t('Front Page Slideshow'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['busi_settings']['slideshow']['no_of_slides'] = array( '#type' => 'textfield', '#title' => t('Number of slides'), '#default_value' => theme_get_setting('no_of_slides'), '#description' => t("Enter the number of slides required & Save configuration"), '#markup' => '
Clear caches after making any changes in theme settings. Click here to clear cashe
', ); $form['busi_settings']['slideshow']['slideshow_display'] = array( '#type' => 'checkbox', '#title' => t('Show slideshow'), '#default_value' => theme_get_setting('slideshow_display', 'bartik'), '#description' => t("Check this option to show Slideshow in front page. Uncheck to hide."), ); $form['busi_settings']['slideshow']['slide'] = array( '#markup' => t('You can change the title, url and image of each slide in the following Slide Setting fieldsets.'), ); for ($i = 1; $i <= theme_get_setting('no_of_slides'); $i++) { $form['busi_settings']['slideshow']['slide' . $i] = array( '#type' => 'details', '#title' => t('Slide '.$i), '#collapsible' => TRUE, '#collapsed' => TRUE, ); $form['busi_settings']['slideshow']['slide' . $i]['slide_title_' . $i] = array( '#type' => 'textfield', '#title' => t('Slide '.$i.' Title'), '#default_value' => theme_get_setting("slide_title_{$i}", "bartik"), ); $form['busi_settings']['slideshow']['slide' . $i]['slide_image_' . $i] = array( '#type' => 'managed_file', '#title' => t('Slide '.$i.' Image'), '#description' => t('Use same size for all the slideshow images(Recommented size : 930 x 320).'), '#default_value' => theme_get_setting("slide_image_{$i}", "bartik"), '#upload_location' => 'public://', ); $form['busi_settings']['slideshow']['slide' . $i]['slide_url_' . $i] = array( '#type' => 'textfield', '#title' => t('Slide '.$i.' URL'), '#default_value' => theme_get_setting("slide_url_{$i}", "bartik"), ); } //$filename = drupal_get_path('theme', 'bartik') . '/bartik.theme'; //$form_state->addBuildInfo('files', array($filename)); // Custom submit to save the file permenant. // $form['#submit'][] = 'bartik_settings_form_submit'; }