Full ELMS Learning Network documentation
function adaptivetheme_preprocess_page
cis7 preprocess.inc | adaptivetheme_preprocess_page(&$vars) |
cle7 preprocess.inc | adaptivetheme_preprocess_page(&$vars) |
elmsmedia7 preprocess.inc | adaptivetheme_preprocess_page(&$vars) |
icor7 preprocess.inc | adaptivetheme_preprocess_page(&$vars) |
meedjum_blog7 preprocess.inc | adaptivetheme_preprocess_page(&$vars) |
mooc7 preprocess.inc | adaptivetheme_preprocess_page(&$vars) |
Preprocess variables for page.tpl.php
File
- sites/
all/ themes/ ulmus/ adaptivetheme/ at_core/ inc/ preprocess.inc, line 131 - All Preprocess functions for templates and theme fucntions. If you need to add or modify preprocess functions do it in your sub-theme.
Code
function adaptivetheme_preprocess_page(&$vars) {
global $theme_key;
$theme_name = $theme_key;
// Set up logo element
if (at_get_setting('toggle_logo', $theme_name) === 1) {
$vars['site_logo'] = &drupal_static('adaptivetheme_preprocess_page_site_logo');
if (empty($vars['site_logo'])) {
$logo_image_path = check_url($vars['logo']);
$logo_image_alt = check_plain(variable_get('site_name', t('Home page')));
$logo_image_vars = array(
'path' => $logo_image_path,
'alt' => $logo_image_alt,
'attributes' => array('class' => 'site-logo'),
);
$vars['logo_img'] = theme('image', $logo_image_vars);
if (at_get_setting('logo_title') == 1) {
$vars['site_logo'] = $vars['logo_img'] ? l($vars['logo_img'], '<front>', array('attributes' => array('title' => $logo_image_alt), 'html' => TRUE)) : '';
}
else {
$vars['site_logo'] = $vars['logo_img'] ? l($vars['logo_img'], '<front>', array('html' => TRUE)) : '';
}
}
// Maintain backwards compatibility with 7.x-2.x sub-themes
$vars['linked_site_logo'] = $vars['site_logo'];
}
else {
$vars['site_logo'] = '';
$vars['logo_img'] = '';
$vars['linked_site_logo'] = '';
}
// Site name
$vars['site_name'] = &drupal_static('adaptivetheme_preprocess_page_site_name');
if (empty($vars['site_name'])) {
$vars['site_name_title'] = variable_get('site_name', 'Drupal');
$vars['site_name'] = l($vars['site_name_title'], '<front>', array('attributes' => array('title' => t('Home page'))));
$vars['site_name_unlinked'] = $vars['site_name_title'];
}
// Site name visibility and other classes and variables
$vars['site_name_attributes_array'] = array();
$vars['visibility'] = '';
$vars['hide_site_name'] = FALSE;
if (at_get_setting('toggle_name', $theme_name) === 0) {
// Keep the visibility variable to maintain backwards compatibility
$vars['visibility'] = 'element-invisible';
$vars['site_name_attributes_array']['class'][] = $vars['visibility'];
$vars['hide_site_name'] = TRUE;
}
// Build a variable for the main menu
if (isset($vars['main_menu'])) {
$main_menu_title = at_get_setting('menu_button_link_text') ? at_get_setting('menu_button_link_text') : t('Main menu');
$vars['primary_navigation'] = theme('links', array(
'links' => $vars['main_menu'],
'attributes' => array(
'class' => array('menu', 'primary-menu', 'clearfix'),
),
'heading' => array(
'text' => $main_menu_title,
'level' => 'h2',
'class' => array('element-invisible'),
'id' => array('primary-menu'),
),
));
}
// Build a variable for the secondary menu
if (isset($vars['secondary_menu'])) {
$vars['secondary_navigation'] = theme('links', array(
'links' => $vars['secondary_menu'],
'attributes' => array(
'class' => array('menu', 'secondary-menu', 'clearfix'),
),
'heading' => array(
'text' => t('Secondary menu'),
'level' => 'h2',
'class' => array('element-invisible'),
'id' => 'secondary-menu',
),
));
}
// Build variables for Primary and Secondary local tasks
$vars['primary_local_tasks'] = menu_primary_local_tasks();
$vars['secondary_local_tasks'] = menu_secondary_local_tasks();
// Add back the $search_box var to D7
if (module_exists('search')) {
$search_box = drupal_get_form('search_form');
$vars['search_box'] = '<div id="search-box" role="search">' . drupal_render($search_box) . '</div>';
}
// Process enabled Extensions
if (at_get_setting('enable_extensions', $theme_name) === 1) {
// Generate page classes, in AT Core these are all Extensions
if ($page_classes = at_generate_page_classes($vars, $theme_name)) {
foreach ($page_classes as $class_name) {
$vars['classes_array'][] = $class_name;
}
}
// Process modify markup settings
if (at_get_setting('enable_markup_overides', $theme_name) === 1) {
// Remove the infernal feed icons
if (at_get_setting('feed_icons_hide', $theme_name) === 1) {
$vars['feed_icons'] = '';
}
}
}
// Strip stupid contextual-links-region class.
//$vars['classes_array'] = array_values(array_diff($vars['classes_array'], array('contextual-links-region')));
// page attributes
$vars['page_attributes_array']['id'][] = 'page';
$vars['page_attributes_array']['class'] = $vars['classes_array'];
// header attributes
$vars['header_attributes_array']['id'][] = 'header';
$vars['header_attributes_array']['class'][] = 'clearfix';
$vars['header_attributes_array']['role'][] = 'banner';
// branding attributes
$vars['branding_attributes_array']['id'][] = 'branding';
$vars['branding_attributes_array']['class'][] = 'branding-elements';
$vars['branding_attributes_array']['class'][] = 'clearfix';
// site name and slogan attributes (wrapper div)
// hgroup maintains BC layer for pre 7.x-3.2 themes
$vars['hgroup_attributes_array'] = array();
if (!$vars['site_slogan'] && $vars['hide_site_name']) {
$vars['hgroup_attributes_array']['class'][] = $vars['visibility'];
}
$vars['hgroup_attributes_array']['class'][] = 'h-group';
$vars['hgroup_attributes_array']['id'][] = 'name-and-slogan';
// site name attributes
$vars['site_name_attributes_array']['id'][] = 'site-name';
// site slogan attributes
$vars['site_slogan_attributes_array']['id'][] = 'site-slogan';
// main content header attributes
$vars['content_header_attributes_array']['id'][] = 'main-content-header';
$vars['content_header_attributes_array']['class'][] = 'clearfix';
// footer attributes
$vars['footer_attributes_array']['id'][] = 'footer';
$vars['footer_attributes_array']['class'][] = 'clearfix';
$vars['footer_attributes_array']['role'][] = 'contentinfo';
// Attribution variable used in admin theme and some others
$vars['attribution'] = '';
if (at_get_setting('attribution_toggle', $theme_name) === 1) {
$vars['attribution'] = "<small class=\"attribution\">Premium Drupal Theme by <a href=\"http://adaptivethemes.com\">Adaptivethemes.com</a></small>";
}
// Work around a perculier bug/feature(?) in Drupal 7 which incorrectly sets
// the page title to "User account" for all three of these pages.
$title = drupal_get_title();
if (arg(0) === 'user' && $title == t('User account')) {
if (arg(1) === 'login' || arg(1) == '') {
drupal_set_title(t('User login'));
}
if (arg(1) === 'password') {
drupal_set_title(t('Request new password'));
}
if (arg(1) === 'register') {
drupal_set_title(t('Create new account'));
}
}
}