Account created on 21 February 2022, almost 3 years ago
#

Recent comments

🇫🇷France racol

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 !

🇫🇷France racol

Your regexs are corrects ;)

Test to reproduce:

  1. Create a page my_super_amazing_webform
  2. URL alias /my_super_amazing_webform
  3. Create Switch theme with #\?is_embed$#
  4. Going to http://rcowebdev.local/my_super_amazing_webform?is_embed, choosen theme applied (attachment is_embed.png)
  5. Going to http://rcowebdev.local/my_super_amazing_webform, default theme applied (attachment not_embed.png)

Pleasure

🇫🇷France racol

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.

http://rcowebdev.local/?is_embed

http://rcowebdev.local/?is_embed=1

Pleasure

🇫🇷France racol

Sorry, I'm late. So I released the version 1.2.0 of Switch Theme including:

  1. Configuration link directly on modules list & Appearance tab
  2. Allowed query parameters in regex theme configuration
  3. 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:

  1. #^/test\?theme=1$#
  2. #^/test\?theme=7$#
  3. #^/test\?theme=1$|^/test\?theme=7$#

I created the article "test" with "/test" alias and applied different themes according to the query parameters

  1. #^/test\?theme=1$# => only the theme for the role & regex choosed is applied
  2. #^/test\?theme=7$# => only the theme for the role & regex choosed is applied
  3. #^/test\?theme=1$|^/test\?theme=7$# only the theme for the role & regex choosed is applied
  4. #^/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

🇫🇷France racol

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

🇫🇷France racol

It's works but let me, before, check the security :) !

Pleasure

🇫🇷France racol

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

🇫🇷France racol

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

🇫🇷France racol

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.

  1. Example 1:
  2. #^/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
    ...

  3. Example 2:
  4. #^/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 "|"

  5. Example 3:
  6. #^/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&param=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

🇫🇷France racol

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:

  1. Download Oracle Virtual Machine
  2. Install Linux Mint Cinnamon 64 on it
  3. Install LAMP (PHP version 8.0.0 & Mysql & Composer) - I believed PHP version was the problem, it seems to be wrong
  4. Download Drupal 9.5.7
  5. Configure virtualhost & Mysql
  6. Install Drupal 9.5.7
  7. Front & Back are up
  8. Install Switch Theme 1.1.0 via composer (composer require 'drupal/switch_theme:^1.1')
  9. Create the article "switch theme test 9.5.7" with the url alias "/switchtheme-test"
  10. Create a new switch theme in "/admin/switch_theme/edit" named "switchtheme-test" for role "Anonymous", Theme "stark" & URI Pattern "#^/switchtheme-test#"
  11. Clear caches
  12. 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

🇫🇷France racol

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

🇫🇷France racol

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

🇫🇷France racol

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:

  1. Download Drupal 9.5.7
  2. Configure virtualhost & MariaDB
  3. Install Drupal 9.5.7
  4. Front & Back are up
  5. Install Switch Theme 1.0.0
  6. Create the article "switch theme test 9.5.7" with the url alias "/switchtheme-test"
  7. Create a new switch theme in "/admin/switch_theme/edit" named "switchtheme-test" for role "Anonymous", Theme "stark" & URI Pattern "#^/switchtheme-test#"
  8. Clear caches
  9. 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

🇫🇷France racol

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

Production build 0.71.5 2024