Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When disabling the default Chosen theme (CSS), Chosen is broken for themes that don't have custom Chosen styling.
Example use case:
You created custom chosen styling for your own front-end theme and therefore disabled the default Chosen CSS.
If the admin theme is different than your front-end theme, and you still want to use Chosen in the back-end, without making changes to that theme, it is not possible to use Chosen in the back-end since the styling is broken.
Proposed resolution
- Make the 'Use the default chosen theme' a per theme setting.
- And flip the CSS inclusion logic. Select the themes you want to exclude instead of deselecting the checkbox.
Patch attached.
Comment | File | Size | Author |
---|---|---|---|
#15 | interdiff-chosen-disable-css-per-theme-2410783-1-15.txt | 752 bytes | mr.york |
#15 | chosen-disable-css-per-theme-2410783-15.patch | 4.34 KB | mr.york |
| |||
#12 | drupal8-make_the_use_the-2410783-12.patch | 6.66 KB | mr.york |
#11 | drupal8-make_the_use_the-2410783-11.patch | 6.38 KB | mr.york |
#10 | drupal8-make_the_use_the-2410783-10.patch | 7.46 KB | mr.york |
Comments
Comment #1
dmsmidtFix .install and some typ0's.
Comment #2
dmsmidtComment #3
cthos CreditAttribution: cthos commentedThis looks good to me, and is a great idea if you want to only have to override the settings on say the frontend, but not the admin theme.
Comment #4
OwilliwOHi !! Great idea.
It works for me.
Drupal 7.37
Chosen 7.x-2.0-beta4
I can now use default CSS for my admin theme (adminimal) and let a front-end developer fully customize it in front theme.
Thanks!!
Comment #5
manumilou CreditAttribution: manumilou commented+1 - Very useful, thx
Comment #6
dmsmidtIf you reviewed the code and this works for you please set the status to RTBC :-)
Comment #7
OwilliwOSimple, but great patch !
Comment #8
marcoka CreditAttribution: marcoka commentedgreat patch. much appreciated. works and is exacly what you need if you want a custom chosen theme.
Comment #9
nagy.balint CreditAttribution: nagy.balint commentedThe patch is great, but unfortunately the update hook does not work properly for me.
If the chosen css is disabled, it is supposed to check all the checkboxes, but for me it just does not happen.
array_keys(_chosen_enabled_themes_options()) produces an empty array in the update hook. Tried setting refresh to TRUE inside it, but did not work. In fact list themes function returns all themes with the status 0 so it will filter out all themes.
The code works fine if I run it separately in devel php, it only fails to provide proper statuses in the update hook (in both update.php and drush updb.)
Let me know if I missed something.
Comment #10
mr.york CreditAttribution: mr.york at Agence Inovae commentedDrupal 8 port.
Comment #11
mr.york CreditAttribution: mr.york at Agence Inovae commentedRemove other issue patch.
Comment #12
mr.york CreditAttribution: mr.york at Agence Inovae commentedHide system theme in the list.
Comment #13
nagy.balint CreditAttribution: nagy.balint commentedSince in Drupal 8 this setting did not work before, and there is no stable release yet, the patch can be committed there without an update hook.
Committed.
Leaving it needs work for the D7 version from Comment #1, which does need a working update hook, otherwise could be committed.
Comment #15
mr.york CreditAttribution: mr.york at Agence Inovae commentedFixed update hook.
Comment #16
mr.york CreditAttribution: mr.york at Agence Inovae commentedComment #21
dmsmidt@nagy.balint Great that this has been committed to D8! (Some credits for my idea and work on the D7 version would have been appreciated for this commit, though..)
Comment #23
nagy.balint CreditAttribution: nagy.balint commented