Hi !
Thanks a lot for your participation !
Sorry for the time I took, I'm working on others subjects actually :)
A new release will be available tomorrow of Taxonomy admin search form! 1.1.0 :) It's a lot of PHP issues (CS).
To tell you the truth, I would like to integrate Taxonomy admin search form to Drupal View system. I haven't understood why the list of terms are not included in the view module as nodes ...
Anyway, see you tomorrow for this minor release :) And if you want to help me, let me know ;)
Pleasure !
Your regexs are corrects ;)
Test to reproduce:
- Create a page my_super_amazing_webform
- URL alias /my_super_amazing_webform
- Create Switch theme with #\?is_embed$#
- Going to http://rcowebdev.local/my_super_amazing_webform?is_embed, choosen theme applied (attachment is_embed.png)
- Going to http://rcowebdev.local/my_super_amazing_webform, default theme applied (attachment not_embed.png)
Pleasure
You can use
#\?is_embed=1$#
or
#\?is_embed$#
In pattern configuration.
You can also create two switch theme if you want both.
I tested it on my local env.
Pleasure
Sorry, I'm late. So I released the version 1.2.0 of Switch Theme including:
- Configuration link directly on modules list & Appearance tab
- Allowed query parameters in regex theme configuration
- Some others corrections on others subjects
To have it, you must uninstall your current version of the module (1.1.0 I think for 1.2.0). If you have a lot of themes configuration, make sure to make a backup of the regex you writed. Don't worry about your website ;)
I advise to you to install the module via composer
composer require 'drupal/switch_theme:^1.2'
For the query parameters, don't forget to escape the "?" character with a "\" ("?" is a special character for regex, so, if you don't escape it, it will be interpreted), below some examples I used for test:
- #^/test\?theme=1$#
- #^/test\?theme=7$#
- #^/test\?theme=1$|^/test\?theme=7$#
I created the article "test" with "/test" alias and applied different themes according to the query parameters
- #^/test\?theme=1$# => only the theme for the role & regex choosed is applied
- #^/test\?theme=7$# => only the theme for the role & regex choosed is applied
- #^/test\?theme=1$|^/test\?theme=7$# only the theme for the role & regex choosed is applied
- #^/test\?theme=2$|^/test\?theme=3$|#^/test\?theme=4$ ... # the default theme will be applied
Let me know if this release is good for you ;).
Pleasure
sorry for the German UI
Don't worry ;), I added a configuration link (attachment 1.png) in "admin/module" list for the custom module Switch theme. This link redirects to the list of switch theme available (attachment 2.png), what do you think ?
Furthermore, I haven't tested completely your case of query parameter for the Switch Theme, a release should be available tomorrow :)
Pleasure
It's works but let me, before, check the security :) !
Pleasure
Thanks for all the examples, great help for all of us who 'fear' REGEX ;)
héhé ;)
Sorry, I should have clarified what's my intention here. I use Switch Theme inside an iframe, so the idea is to simply add a "?is-embed" query parameter, to switch the theme in this case.
Don't worry, actually, you can't with this Switch Theme module version because of only the URI is concerned by the theme negociator as "/news", "/toto", etc but not query parameters as "/news?toto=joe" as regex even if you have escaped the "?".
I have tested myself - not via an iframe but it should be the same behaviour - and modified the theme negociator to resolve your problem.
/modules/custom/switch_theme/src/Theme/ThemeNegotiator.php
Just replace
l.89 $requestUri = strtok(\Drupal::request()->getRequestUri(), '?');
by
l.89 $requestUri = \Drupal::request()->getRequestUri();
What does it mean ? For the Switch theme module, only URI is important, I haven't develop this module to take care of query parameters to adapt theme depending only of parameters in the URL (caching problem, take care about that ! :/ )
but this solution works, not the best at all, but it works for your problem.
Let me know if the problem is solved :).
Pleasure
Good idea,
but I didn't want my module to depend on another one but only on Drupal core (easy install, anyway, you know :) ).
I use it on many of my sites and no dependencies are needed other than Drupal core.
The simplest solution is often the best :)!
I will of course think about it but to be honest with you, as long as it works ... ^^, I am interested in other subjects.
I will focus more on taxonomy search admin form (" https://www.drupal.org/project/taxonomy_search_admin_form → "), it seems quite appreciated by the community.
It goes without saying that I continue to take care of the two modules which are being proofread by ... me. And a "News" module similar to an X (Twitter) or Facebook for Drupal 9|10; finished but not tested on a large scale (only 1000 users on a dedicated server).
Looking forward to giving you access to the contribution on GIT for:
- https://git.drupalcode.org/project/taxonomy_search_admin_form
- https://git.drupalcode.org/project/switch_theme
pleasure
the pattern requested is a regex (or regexs concatanated) which will be used by the theme negotiator to know if the current URI must apply or not the theme choosen in the tab "Appearance/Switch Theme".
You must have a little knowledge about how to write regex.
- Example 1:
- Example 2:
- Example 3:
#^/second-part-theme#
# : regex delimiter
^ : must begin by "/second-part-theme"
In this case, all URL wich match "https://www.your-website.com/second-part-theme", the choosen theme for this pattern will be applied
https://www.your-website.com/second-part-theme
https://www.your-website.com/second-part-theme/sub-part
https://www.your-website.com/second-part-theme/sub-part/sub-part-2
...
#^/cms-page-presentation$#
# : regex delimiter
^ : must begin by "/cms-page-presentation"
$ : must end by "/cms-page-presentation"
so in this case, the theme will be applied only for
https://www.your-website.com/cms-page-presentation
You can concatanate regexs with a "|"
#^/cms-page-presentation$|^/second-part-theme|^/test$#
# : regex delimiter
^ : must begin by "/cms-page-presentation" OR "/second-part-theme" OR "/test"
$ : must end by "/cms-page-presentation" OR "/test"
| : regexs concatanator
In this case, the theme will be applied for thoses URLS
https://www.your-website.com/cms-page-presentation
https://www.your-website.com/second-part-theme
https://www.your-website.com/second-part-theme/sub-part
https://www.your-website.com/second-part-theme/sub-part/sub-part-2
...
https://www.your-website.com/test
In case of query parameter like "/news?page=10" or "/news?page=10&order=ASC¶m=doe&...", you don't need to specify query parameters in the URI pattern configuration, the "/news" condition is sufficient to do what you want and query parameters will be always available for the Drupal system or for your custom module.
I'm going to update the documentation to say explicitly that a regex is asked, not an URI with query paramaters.
Pleasure
Hi,
mh, I think you haven't get the good version of the module if you have the exact same error.
Step by step debugging:
- Download Oracle Virtual Machine
- Install Linux Mint Cinnamon 64 on it
- Install LAMP (PHP version 8.0.0 & Mysql & Composer) - I believed PHP version was the problem, it seems to be wrong
- Download Drupal 9.5.7
- Configure virtualhost & Mysql
- Install Drupal 9.5.7
- Front & Back are up
- Install Switch Theme 1.1.0 via composer (composer require 'drupal/switch_theme:^1.1')
- Create the article "switch theme test 9.5.7" with the url alias "/switchtheme-test"
- Create a new switch theme in "/admin/switch_theme/edit" named "switchtheme-test" for role "Anonymous", Theme "stark" & URI Pattern "#^/switchtheme-test#"
- Clear caches
- Go to "/switchtheme-test", the theme stark is used, go to home, the default front theme is used
Everything works for me (on APACHE & NGINX), can you please share to me your configuration ? (WEB server & version, DB server & version, PHP version & OS ?
Thank you in advance !
Pleasure
Hi,
my bad, after some investigations, the release 1.0.0 is not the last one ( :/ ) , 1.1.0 is. I updated it on the drupal module page.
So, you just need to desinstall the current switch theme module & take the release 1.1.0 (via composer or manually) & install it.
Sorry for this inconvenience !
Pleasure
Hi,
my bad, the release 1.0.0 is not the last one, 1.1.0 is. I updated it on the drupal module page.
So, you just need to desinstall the current switch theme module & take the release 1.1.0 (via composer or manually) & install it.
Sorry for this inconvenience !
Pleasure
Hi,
I installed a fresh install of Drupal 9.5.7 on an Apache server and I can't reproduce your issue.
Step by step debugging:
- Download Drupal 9.5.7
- Configure virtualhost & MariaDB
- Install Drupal 9.5.7
- Front & Back are up
- Install Switch Theme 1.0.0 →
- Create the article "switch theme test 9.5.7" with the url alias "/switchtheme-test"
- Create a new switch theme in "/admin/switch_theme/edit" named "switchtheme-test" for role "Anonymous", Theme "stark" & URI Pattern "#^/switchtheme-test#"
- Clear caches
- Go to "/switchtheme-test", the theme stark is used, go to home, the default front theme is used
My own configuration:
- WEB Server: Apache/2.4.54 (Win64) OpenSSL/1.1.1p PHP/8.2.0
- DB Server: MariaDB 10.4.27-MariaDB
- PHP Version: 8.2.0
What is your configuration please ?
I had some pictures, if you have any question, just let me know !
Pleasure
Hi,
Working on it !
Pleasure
Hi !
where should have add it ? In the README.md or drupal.org website or both ? is there a particular synthax to do this ?
Thanks a lot