Commit f8aa6c2e authored by alexpott's avatar alexpott

Issue #2404929 by dileepmaurya, segi, Kristen Pol, prajaankit: Path class on...

Issue #2404929 by dileepmaurya, segi, Kristen Pol, prajaankit: Path class on <body> may be language specific, results in CSS bugs
parent efbeab2c
...@@ -1343,8 +1343,15 @@ function template_preprocess_html(&$variables) { ...@@ -1343,8 +1343,15 @@ function template_preprocess_html(&$variables) {
// Add a variable for the root path. This can be used to create a class and // Add a variable for the root path. This can be used to create a class and
// theme the page depending on the current path (e.g. node, admin, user) as // theme the page depending on the current path (e.g. node, admin, user) as
// well as more specific data like path-frontpage. // well as more specific data like path-frontpage.
$path = \Drupal::request()->getPathInfo(); $is_front_page = \Drupal::service('path.matcher')->isFrontPage();
$variables['root_path'] = explode('/', $path)[1];
if ($is_front_page) {
$variables['root_path'] = TRUE;
}
else {
$system_path = \Drupal::request()->attributes->get('_system_path');
$variables['root_path'] = explode('/', $system_path)[0];
}
$site_config = \Drupal::config('system.site'); $site_config = \Drupal::config('system.site');
// Construct page title. // Construct page title.
...@@ -1356,7 +1363,7 @@ function template_preprocess_html(&$variables) { ...@@ -1356,7 +1363,7 @@ function template_preprocess_html(&$variables) {
} }
// @todo Remove once views is not bypassing the view subscriber anymore. // @todo Remove once views is not bypassing the view subscriber anymore.
// @see http://drupal.org/node/2068471 // @see http://drupal.org/node/2068471
elseif (drupal_is_front_page()) { elseif ($is_front_page) {
$head_title = array( $head_title = array(
'title' => t('Home'), 'title' => t('Home'),
'name' => String::checkPlain($site_config->get('name')), 'name' => String::checkPlain($site_config->get('name')),
......
...@@ -163,7 +163,6 @@ protected function doTestLanguageBlockAnonymous($block_label) { ...@@ -163,7 +163,6 @@ protected function doTestLanguageBlockAnonymous($block_label) {
/** /**
* Test languge switcher links for domain based negotiation * Test languge switcher links for domain based negotiation
*/ */
function testLanguageBlockWithDomain() { function testLanguageBlockWithDomain() {
// Add the Italian language. // Add the Italian language.
ConfigurableLanguage::createFromLangcode('it')->save(); ConfigurableLanguage::createFromLangcode('it')->save();
...@@ -241,6 +240,33 @@ function testLanguageLinkActiveClass() { ...@@ -241,6 +240,33 @@ function testLanguageLinkActiveClass() {
$this->doTestLanguageLinkActiveClassAnonymous(); $this->doTestLanguageLinkActiveClassAnonymous();
} }
/**
* Check the path-admin class, as same as on default language.
*/
function testLanguageBodyClass() {
$searched_class = 'path-admin';
// Add language.
$edit = array(
'predefined_langcode' => 'fr',
);
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable URL language detection and selection.
$edit = array('language_interface[enabled][language-url]' => '1');
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Go to admin/config, check the class on default language.
$this->drupalGet('admin/config');
$class = $this->xpath('//body[contains(@class, :class)]', array(':class' => $searched_class));
$this->assertTrue(isset($class[0]), t('The path-admin class appears on default language.'));
// Go to admin/config, check the class on french language.
$this->drupalGet('fr/admin/config');
$class = $this->xpath('//body[contains(@class, :class)]', array(':class' => $searched_class));
$this->assertTrue(isset($class[0]), t('The path-admin class same as on default language.'));
}
/** /**
* For authenticated users, the "active" class is set by JavaScript. * For authenticated users, the "active" class is set by JavaScript.
* *
......
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