Untitled
unknown
plain_text
4 years ago
1.7 kB
16
Indexable
<?php
/**
* @file
* Bootstrap sub-theme.
*
* Place your custom PHP code in this file.
*/
use Drupal\taxonomy\Entity\Term;
use Drupal\Component\Utility\Html;
/**
* Implements theme_preprocess_html().
*/
function smhsbootstrap_preprocess_html(&$variables) {
$variables['smhsbootstrap_subtheme_options'] = theme_get_setting('smhsbootstrap_subtheme_options');
/*
// Add node ID to the body class.
$node = \Drupal::routeMatch()->getParameter('node');
if (is_object($node)) {
$variables['attributes']['class'][] = 'node-' . $node->id();
}
*/
if ($node = \Drupal::routeMatch()->getParameter('node')) {
/*
* Get the term id from the 'field_section' taxonomy field.
* If greater than zero, load the term and acquire the name value
* as a css safe value.
*/
/*
if ($node->hasField('field_section')) {
$tid = $node->get('field_section')->target_id;
if ($tid > 0) {
$term_object = Term::load($tid);
$variables['attributes']['class'][] = 'terms--' . Html::getClass($term_object->get('name')->value);
}
}
*/
/*
* Get the node id from the node object.
* If greater than zero, add the node id to body classes
* Get the node type from the node object.
* If not none, add the node type to body classes
*/
$nid = $node->get('nid')->value;
if ($nid > 0) {
$variables['attributes']['class'][] = 'page--node-' . $nid;
//$type = isset($node->type) ? $node->type : 'none';
//$type = ($type == 'none' && arg(0) == 'node' && arg(1) == 'add') ? arg(2) : $type;
//$variables['attributes']['class'][] = 'content-type-' . $type;
}
}
}
Editor is loading...