-
Notifications
You must be signed in to change notification settings - Fork 0
/
wellspring.theme
37 lines (32 loc) · 953 Bytes
/
wellspring.theme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity;
use Drupal\taxonomy\Entity\Term;
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface;
use Drupal\media\MediaInterface;
use Drupal\Core\Render\Markup;
/**
* @file
* Add url alias to body as class.
*/
/**
*
*/
function wellspring_preprocess_html(&$variables) {
$current_path = Drupal::service('path.current')->getPath();
$path_alias = Drupal::service('path_alias.manager')->getAliasByPath($current_path);
$path_alias = 'alias-' . ltrim($path_alias, '/');
$variables['attributes']['class'][] = Html::cleanCssIdentifier($path_alias);
}
/**
* Implements hook_theme_suggestions_page_alter().
*/
function wellspring_theme_suggestions_page_alter(array &$suggestions, array $variables) {
if ($node = Drupal::routeMatch()->getParameter('node')) {
if(!is_object($node)) {
$node = Node::load($node);
}
$suggestions[] = 'page__' . $node->bundle();
}
}