diff --git a/README.txt b/README.txt
index d288f5b..430cf6f 100644
--- a/README.txt
+++ b/README.txt
@@ -13,6 +13,7 @@ FEATURES
- Theme can be set for single page or list of pages.
- Theme can be assigned to specific roles.
- Wildcard '*' character can be used in drupal paths.
+ - Supports query value for theme_key.
- Supports Multi domain sites.
- Supports Multilingual sites.
diff --git a/src/Form/SwitchPageThemeSettingForm.php b/src/Form/SwitchPageThemeSettingForm.php
index da32015..30492f6 100644
--- a/src/Form/SwitchPageThemeSettingForm.php
+++ b/src/Form/SwitchPageThemeSettingForm.php
@@ -108,13 +108,14 @@ class SwitchPageThemeSettingForm extends ConfigFormBase {
}
$form['desc'] = [
'#type' => 'markup',
- '#markup' => $this->t('Enabled: Rule will work only if checkbox is checked.
Pages: Enter one path per line. The "*" character is a wildcard. Example paths are "/node/1" for an individual piece of content or "/node/*" for every piece of content. "@front" is the front page.
@availableSettings: Select none to allow all.
Theme with highest weight will be applied on the page.', ['@availableSettings' => $availableSettings, '@front' => '']),
+ '#markup' => $this->t('Enabled: Rule will work only if checkbox is checked.
Pages: Enter one path per line. The "*" character is a wildcard. Example paths are "/node/1" for an individual piece of content or "/node/*" for every piece of content. "@front" is the front page.
Theme key: Enter the theme key value to access the selected theme, e.g. ?theme_key=AAABBBCCC
@availableSettings: Select none to allow all.
Theme with highest weight will be applied on the page.', ['@availableSettings' => $availableSettings, '@front' => '']),
];
// Create headers for table.
$header = [
$this->t('Enabled'),
$this->t('pages'),
+ $this->t('Theme Key'),
$this->t('Themes'),
$this->t('Roles'),
];
@@ -171,7 +172,7 @@ class SwitchPageThemeSettingForm extends ConfigFormBase {
'#type' => 'checkbox',
'#title' => $this->t('Status'),
'#title_display' => 'invisible',
- '#default_value' => isset($value['status']) ? $value['status'] : NULL,
+ '#default_value' => isset($value['status']) ? $value['status'] : [],
];
$form['spt_table'][$i]['pages'] = [
@@ -184,6 +185,14 @@ class SwitchPageThemeSettingForm extends ConfigFormBase {
'#default_value' => isset($value['pages']) ? $value['pages'] : [],
];
+ $form['spt_table'][$i]['theme_key'] = [
+ '#type' => 'textfield',
+ '#title' => $this->t('Theme Key'),
+ '#title_display' => 'invisible',
+ '#size' => 20,
+ '#default_value' => isset($value['theme_key']) ? $value['theme_key'] : [],
+ ];
+
$form['spt_table'][$i]['theme'] = [
'#type' => 'select',
'#title' => $this->t('Theme'),
diff --git a/src/Theme/PageThemeNegotiator.php b/src/Theme/PageThemeNegotiator.php
index 338540a..839183e 100644
--- a/src/Theme/PageThemeNegotiator.php
+++ b/src/Theme/PageThemeNegotiator.php
@@ -128,7 +128,12 @@ class PageThemeNegotiator implements ThemeNegotiatorInterface {
// Check if rule is enabled.
if ($value['status'] == 1) {
// Check condition for basic rules.
- $condition = ($this->request->getCurrentRequest()->attributes->get("_route") != "system.403" && ($this->pathMatcher->matchPath($this->currentPath->getPath(), $value["pages"]) || $this->pathMatcher->matchPath($this->pathAlias->getAliasByPath($this->currentPath->getPath()), $value["pages"])) && (!array_filter($value["roles"]) || !empty(array_intersect($value["roles"], $this->account->getRoles()))));
+ $condition = (
+ $this->request->getCurrentRequest()->attributes->get("_route") != "system.403" &&
+ ($this->pathMatcher->matchPath($this->currentPath->getPath(), $value["pages"]) || $this->pathMatcher->matchPath($this->pathAlias->getAliasByPath($this->currentPath->getPath()), $value["pages"])) &&
+ (!empty($value["theme_key"]) && $this->request->getCurrentRequest()->get('theme_key') == $value["theme_key"]) &&
+ (!array_filter($value["roles"]) || !empty(array_intersect($value["roles"], $this->account->getRoles())))
+ );
// Check if domain module is enabled.
if ($this->moduleHandler->moduleExists('domain') && !empty($this->negotiator->getActiveDomain())) {