/** * Implements template_preprocess_page(). */ function radix_preprocess_page(&$variables) { global $base_url; // Add Bootstrap JS. $base = parse_url($base_url); drupal_add_js($base['scheme'] . '://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js', 'external'); // Add CSS for Font Awesome // drupal_add_css('//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css', 'external'); // Determine if the page is rendered using panels. $variables['is_panel'] = FALSE; if (module_exists('page_manager') && count(page_manager_get_current_page())) { $variables['is_panel'] = TRUE; } // Make sure tabs is empty. if (empty($variables['tabs']['#primary']) && empty($variables['tabs']['#secondary'])) { $variables['tabs'] = ''; } // Add search_form to theme. $variables['search_form'] = ''; if (module_exists('search') && user_access('search content')) { $search_box_form = drupal_get_form('search_form'); $search_box_form['basic']['keys']['#title'] = ''; $search_box_form['basic']['keys']['#attributes'] = array('placeholder' => 'Search'); $search_box_form['basic']['keys']['#attributes']['class'][] = 'search-query'; $search_box_form['basic']['submit']['#value'] = t('Search'); $search_box_form['#attributes']['class'][] = 'navbar-form'; $search_box_form['#attributes']['class'][] = 'pull-right'; $search_box = drupal_render($search_box_form); $variables['search_form'] = user_access('search content') ? $search_box : NULL; } // Format and add main menu to theme. $variables['main_menu'] = menu_tree(variable_get('menu_main_links_source', 'main-menu')); $variables['main_menu']['#theme_wrappers'] = array('menu_tree__primary'); // Add a copyright message. $variables['copyright'] = t('Drupal is a registered trademark of Dries Buytaert.'); // Display a message if Sass has not been compiled. $theme_path = drupal_get_path('theme', $GLOBALS['theme']); $stylesheet_path = $theme_path . '/assets/stylesheets/screen.css'; if (_radix_current_theme() == 'radix') { $stylesheet_path = $theme_path . '/assets/stylesheets/radix-style.css'; } if (!file_exists($stylesheet_path)) { drupal_set_message(t('It looks like %path has not been created yet. Run <code>@command</code> in your theme directory to create it.', array('%path' => $stylesheet_path, '@command' => 'compass watch')), 'error'); } }
/** * Implements template_preprocess_page(). */ function radix_preprocess_page(&$variables) { global $base_url; // Add Bootstrap JS from CDN if bootstrap library is not installed. if (!module_exists('bootstrap_library')) { $base = parse_url($base_url); drupal_add_js($base['scheme'] . '://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js', 'external'); } // Add support for the Modenizr module. // Load modernizr.js only if modernizr module is not present. if (!module_exists('modernizr')) { drupal_add_js(drupal_get_path('theme', 'radix') . '/assets/javascripts/modernizr.js'); } // Determine if the page is rendered using panels. $variables['is_panel'] = FALSE; if (module_exists('page_manager') && count(page_manager_get_current_page())) { $variables['is_panel'] = TRUE; } // Make sure tabs is empty. if (empty($variables['tabs']['#primary']) && empty($variables['tabs']['#secondary'])) { $variables['tabs'] = ''; } // Theme action links as buttons. foreach ($variables['action_links'] as $key => &$link) { $link['#link']['localized_options']['attributes'] = array('class' => array('btn', 'btn-primary')); } // Add search_form to theme. $variables['search_form'] = ''; if (module_exists('search') && user_access('search content')) { $search_box_form = drupal_get_form('search_form'); $search_box_form['basic']['keys']['#title'] = ''; $search_box_form['basic']['keys']['#size'] = 20; $search_box_form['basic']['keys']['#attributes'] = array('placeholder' => 'Search'); $search_box_form['basic']['keys']['#attributes']['class'][] = 'form-control'; $search_box_form['basic']['submit']['#value'] = t('Search'); $search_box_form['#attributes']['class'][] = 'navbar-form'; $search_box_form['#attributes']['class'][] = 'navbar-right'; $search_box = drupal_render($search_box_form); $variables['search_form'] = user_access('search content') ? $search_box : NULL; } // Format and add main menu to theme. $variables['main_menu'] = menu_tree(variable_get('menu_main_links_source', 'main-menu')); $variables['main_menu']['#theme_wrappers'] = array(); // Add a copyright message. $variables['copyright'] = t('Drupal is a registered trademark of Dries Buytaert.'); // Display a message if Sass has not been compiled. $theme_path = drupal_get_path('theme', $GLOBALS['theme']); $stylesheet_path = $theme_path . '/assets/stylesheets/screen.css'; if (_radix_current_theme() == 'radix') { $stylesheet_path = $theme_path . '/assets/stylesheets/radix-style.css'; } elseif (_radix_base_theme() == 'radix') { $stylesheet_path = $theme_path . '/assets/stylesheets/screen.css'; } else { // If this isn't radix and it isn't a *direct* sub-theme, then we don't // perform this check (ie. if it's a sub-sub-theme). $stylesheet_path = NULL; } if ($stylesheet_path && !file_exists($stylesheet_path)) { drupal_set_message(t('It looks like %path has not been created yet. Run <code>@command</code> in your theme directory to create it.', array('%path' => $stylesheet_path, '@command' => 'compass watch')), 'error'); } }