1 template.php | basis_preprocess_page(&$variables) |
Prepares variables for page templates.
See also
File
- core/
themes/ basis/ template.php, line 38 - Basis preprocess functions and theme function overrides.
Code
function basis_preprocess_page(&$variables) {
$node = menu_get_object();
// Add the OpenSans font from core on every page of the site.
backdrop_add_library('system', 'opensans', TRUE);
// To add a class 'page-node-[nid]' to each page.
if ($node) {
$variables['classes'][] = 'page-node-' . $node->nid;
}
// To add a class 'view-name-[name]' to each page.
$view = views_get_page_view();
if ($view) {
$variables['classes'][] = 'view-name-' . $view->name;
}
// The CSS update option can be one of the following:
// - install: Calculate the CSS update version based on core install_version.
// - all: Apply all CSS updates.
// - version: Select a specific update version (and all updates prior to it).
$update_preference = theme_get_setting('css_update');
// Get the specified CSS update version.
// The version must be one of the values from basis_updated_css_versions().
// This may also be an empty string, to signify "No updates".
$update_version = theme_get_setting('css_update_version');
// Process supplemental CSS versions as body classes.
$update_css_versions = basis_updated_css_versions();
foreach ($update_css_versions as $update_css_version) {
if ($update_preference === 'all' || version_compare($update_version, $update_css_version, '>=')) {
$update_css_version_class = 'update-' . str_replace('.', '-', $update_css_version);
$variables['classes'][] = $update_css_version_class;
}
}
}