Skip to content
Snippets Groups Projects
Commit f8aa6c2e authored by Alex Pott's avatar Alex Pott
Browse files

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
No related branches found
No related tags found
No related merge requests found
......@@ -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
// theme the page depending on the current path (e.g. node, admin, user) as
// well as more specific data like path-frontpage.
$path = \Drupal::request()->getPathInfo();
$variables['root_path'] = explode('/', $path)[1];
$is_front_page = \Drupal::service('path.matcher')->isFrontPage();
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');
// Construct page title.
......@@ -1356,7 +1363,7 @@ function template_preprocess_html(&$variables) {
}
// @todo Remove once views is not bypassing the view subscriber anymore.
// @see http://drupal.org/node/2068471
elseif (drupal_is_front_page()) {
elseif ($is_front_page) {
$head_title = array(
'title' => t('Home'),
'name' => String::checkPlain($site_config->get('name')),
......
......@@ -163,7 +163,6 @@ protected function doTestLanguageBlockAnonymous($block_label) {
/**
* Test languge switcher links for domain based negotiation
*/
function testLanguageBlockWithDomain() {
// Add the Italian language.
ConfigurableLanguage::createFromLangcode('it')->save();
......@@ -241,6 +240,33 @@ function testLanguageLinkActiveClass() {
$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.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment