Commit 2f9be00c authored by catch's avatar catch

Issue #2736391 by LoMo, rooby, lauriii, leolando.tan: Node type body class is...

Issue #2736391 by LoMo, rooby, lauriii, leolando.tan: Node type body class is not present on node preview page
parent e7f061d5
...@@ -547,9 +547,12 @@ function template_preprocess_node_add_list(&$variables) { ...@@ -547,9 +547,12 @@ function template_preprocess_node_add_list(&$variables) {
* Implements hook_preprocess_HOOK() for HTML document templates. * Implements hook_preprocess_HOOK() for HTML document templates.
*/ */
function node_preprocess_html(&$variables) { function node_preprocess_html(&$variables) {
// If on an individual node page, add the node type to body classes. // If on an individual node page or node preview page, add the node type to
if (($node = \Drupal::routeMatch()->getParameter('node')) && $node instanceof NodeInterface) { // the body classes.
$variables['node_type'] = $node->getType(); if (($node = \Drupal::routeMatch()->getParameter('node')) || ($node = \Drupal::routeMatch()->getParameter('node_preview'))) {
if ($node instanceof NodeInterface) {
$variables['node_type'] = $node->getType();
}
} }
} }
......
...@@ -183,6 +183,10 @@ public function testPagePreview() { ...@@ -183,6 +183,10 @@ public function testPagePreview() {
$this->assertText($edit[$term_key], 'Term displayed.'); $this->assertText($edit[$term_key], 'Term displayed.');
$this->assertLink(t('Back to content editing')); $this->assertLink(t('Back to content editing'));
// Check that we see the class of the node type on the body element.
$body_class_element = $this->xpath("//body[contains(@class, 'page-node-type-page')]");
$this->assertTrue(!empty($body_class_element), 'Node type body class found.');
// Get the UUID. // Get the UUID.
$url = parse_url($this->getUrl()); $url = parse_url($this->getUrl());
$paths = explode('/', $url['path']); $paths = explode('/', $url['path']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment