- Issue created by @Jaime_Pomales
- Status changed to Postponed: needs info
about 1 year ago 1:20pm 30 September 2023 - πΊπ¦Ukraine abramm Lutsk
Hi Jaime_Pomales,
I don't thing the module should include any quirks for other modules, being it civicrm, commerce, or anything else; that's just outside of its scope.You have a few options options here:
1) Either submit a patch enabling flexible configuration (which would in turn allow you configuring the module the way you need it).
or
2) Submit the patch extending the ThemeSwitchNegotiator with a new event which could be dispatched in applies() which you could then subscribe to in your own custom code. - π΅π·Puerto Rico Jaime_Pomales
Yes, I think you raise a fair point.
I'll give it some thought and see what I can do.
- π΅π·Puerto Rico Jaime_Pomales
After some investigation, perhaps maybe just modifying the theme priority:
services: theme.negotiator.domain_theme_switch: class: Drupal\domain_theme_switch\Theme\ThemeSwitchNegotiator arguments: ['@router.admin_context','@current_user','@domain.negotiator','@config.factory'] tags: - { name: theme_negotiator, priority: 10 }
By changing priority to 0 theme switcher should respect other theme route priorities over itself, especially an admin theme.
After I changed my installation to priority 0 the admin theme is respected by domain_theme_switcher when in civicrm's admin area.
- πΊπ¦Ukraine abramm Lutsk
That really sounds like a breaking change and would definitely affect other users.
I'd suggest just altering services on your side ( https://www.drupal.org/docs/drupal-apis/services-and-dependency-injectio... β ) to change the priority if it works for you.
- π΅π·Puerto Rico Jaime_Pomales
Yes of course, that's always possible, but the problem is that this module breaks normal admin theme functionality of the civicrm module, which is used by thousands of sites.
In my own case, modifying the priority did not affect my multiple domain setup negatively. All domain/themes were selected properly as expected, and the backend of civicrm stayed with its admin theme.
CiviCRM a well supported module and has been around for decades at this point. When domain_theme_switch is enabled, it takes over the admin theme priority in situations where the admin theme previously worked as expected.
I know it's a relatively small edge case, but I would suggest perhaps a less aggressive default theme priority as a way to make this module more useful out of the box when interacting with CiviCRM installs.
- πΊπ¦Ukraine abramm Lutsk
What's interesting is that the default theme negotiator in core has priority
-100
so both0
and10
are fine with core.
However, CiviCRM theme has its own negotiator with0
priority:https://github.com/civicrm/civicrm-drupal/blob/8.x-5.2/modules/civicrmth...
As you've suggested, changing
domain_theme_switch
's priority to0
may work (or may not - depends on how specific Drupal version service collector handles ordering of tagged services with same priority).We could go a little bit further an change the priority to
-1
but I've just looked quickly through one of my projects and found at leastwebform
module which has zero priority theme negotiator and could be affected.Maybe a simple submodule (e.g.
domain_theme_switch_civicrm
ordomain_theme_switch_priority
) with service provider altering the priority would work? That should cover the case and would be backwards compatible. - π΅π·Puerto Rico Jaime_Pomales
Thank you for looking into it as well! I appreciate that you are dedicated to doing things the right way. I'm in your debt.
I think what you have suggested is the best solution to sort this out.
- Status changed to Closed: works as designed
about 1 year ago 1:37pm 4 October 2023 - πΊπ¦Ukraine abramm Lutsk
You're welcome Jaime_Pomales, please reopen the issue and let me know if you'd want to contribute the MR with submodule changing the priority.
I'm closing the ticket for now.