Functions to support theming in the Bartik theme.
<?php
/**
* @file
* Functions to support theming in the Bartik theme.
*/
/**
* Implements hook_preprocess_HOOK() for html.tpl.php.
*
* Adds body classes if certain regions have content.
*/
function bartik_preprocess_html(&$variables) {
if (!empty($variables['page']['featured'])) {
$variables['attributes']['class'][] = 'featured';
}
if (!empty($variables['page']['triptych_first']) || !empty($variables['page']['triptych_middle']) || !empty($variables['page']['triptych_last'])) {
$variables['attributes']['class'][] = 'triptych';
}
if (!empty($variables['page']['footer_firstcolumn']) || !empty($variables['page']['footer_secondcolumn']) || !empty($variables['page']['footer_thirdcolumn']) || !empty($variables['page']['footer_fourthcolumn'])) {
$variables['attributes']['class'][] = 'footer-columns';
}
}
/**
* Implements hook_process_HOOK() for html.tpl.php.
*/
function bartik_process_html(&$variables) {
// Hook into color.module.
if (module_exists('color')) {
_color_html_alter($variables);
}
}
/**
* Implements hook_process_HOOK() for page.tpl.php.
*/
function bartik_process_page(&$variables) {
$site_config = config('system.site');
// Hook into color.module.
if (module_exists('color')) {
_color_page_alter($variables);
}
// Always print the site name and slogan, but if they are toggled off, we'll
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
$variables['site_name'] = check_plain($site_config
->get('name'));
}
if ($variables['hide_site_slogan']) {
// If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
$variables['site_slogan'] = filter_xss_admin($site_config
->get('slogan'));
}
// 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'] = array(
'#markup' => '<div class="shortcut-wrapper clearfix">',
'#weight' => 100,
);
$variables['title_suffix']['shortcut_wrapper'] = array(
'#markup' => '</div>',
'#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.tpl.php.
*/
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'] = '';
}
drupal_add_css(drupal_get_path('theme', 'bartik') . '/css/maintenance-page.css');
}
/**
* Implements hook_process_HOOK() for maintenance-page.tpl.php.
*/
function bartik_process_maintenance_page(&$variables) {
$site_config = config('system.site');
// Always print the site name and slogan, but if they are toggled off, we'll
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
$variables['site_name'] = check_plain($site_config
->get('name'));
}
if ($variables['hide_site_slogan']) {
// If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
$variables['site_slogan'] = filter_xss_admin($site_config
->get('slogan'));
}
}
/**
* Implements hook_preprocess_HOOK() for block.tpl.php.
*/
function bartik_preprocess_block(&$variables) {
// In the header and footer regions visually hide block titles.
if ($variables['block']->region == 'header' || $variables['block']->region == 'footer') {
$variables['title_attributes']['class'][] = 'element-invisible';
}
}
/**
* Implements theme_menu_tree().
*/
function bartik_menu_tree($variables) {
return '<ul class="menu clearfix">' . $variables['tree'] . '</ul>';
}
/**
* Implements theme_field__field_type().
*/
function bartik_field__taxonomy_term_reference($variables) {
$output = '';
// Render the label, if it's not hidden.
if (!$variables['label_hidden']) {
$output .= '<h3 class="field-label">' . $variables['label'] . ': </h3>';
}
// Render the items.
$output .= $variables['element']['#label_display'] == 'inline' ? '<ul class="links inline">' : '<ul class="links">';
foreach ($variables['items'] as $delta => $item) {
$output .= '<li class="taxonomy-term-reference-' . $delta . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</li>';
}
$output .= '</ul>';
// Render the top-level DIV.
$variables['attributes']['class'][] = 'clearfix';
$output = '<div ' . $variables['attributes'] . '>' . $output . '</div>';
return $output;
}
Name | Description |
---|---|
bartik_field__taxonomy_term_reference | Implements theme_field__field_type(). |
bartik_menu_tree | Implements theme_menu_tree(). |
bartik_preprocess_block | Implements hook_preprocess_HOOK() for block.tpl.php. |
bartik_preprocess_html | Implements hook_preprocess_HOOK() for html.tpl.php. |
bartik_preprocess_maintenance_page | Implements hook_preprocess_HOOK() for maintenance-page.tpl.php. |
bartik_process_html | Implements hook_process_HOOK() for html.tpl.php. |
bartik_process_maintenance_page | Implements hook_process_HOOK() for maintenance-page.tpl.php. |
bartik_process_page | Implements hook_process_HOOK() for page.tpl.php. |