I've applied a few rules to use a custom CSS file using the experimental Themekey CSS. The first one worked a treat. The second one however did not work.
After some minor digging I found that theres a css file in the business theme called colors.css thats being applied after the one I applied with themekey, meaning I can't overwrite it.
Can see here both style.css and colors.css are applied after the css from themekey.
<style type="text/css" media="all">
@import url("http://mysite.co.uk/modules/system/system.base.css?nrg18t");
@import url("http://mysite.co.uk/modules/system/system.menus.css?nrg18t");
@import url("http://mysite.co.uk/modules/system/system.messages.css?nrg18t");
@import url("http://mysite.co.uk/modules/system/system.theme.css?nrg18t");
</style>
<style type="text/css" media="all">
@import url("http://mysite.co.uk/modules/contextual/contextual.css?nrg18t");
</style>
<style type="text/css" media="all">
@import url("http://mysite.co.uk/sites/all/modules/commerce_add_to_cart_confirmation/css/commerce_add_to_cart_confirmation.css?nrg18t");
@import url("http://mysite.co.uk/sites/all/modules/date/date_api/date.css?nrg18t");
@import url("http://mysite.co.uk/sites/all/modules/date/date_popup/themes/datepicker.1.7.css?nrg18t");
@import url("http://mysite.co.uk/modules/field/theme/field.css?nrg18t");
@import url("http://mysite.co.uk/modules/node/node.css?nrg18t");
@import url("http://mysite.co.uk/modules/poll/poll.css?nrg18t");
@import url("http://mysite.co.uk/modules/search/search.css?nrg18t");
@import url("http://mysite.co.uk/modules/user/user.css?nrg18t");
@import url("http://mysite.co.uk/sites/all/modules/views/css/views.css?nrg18t");
@import url("http://mysite.co.uk/sites/all/modules/admin_menu/admin_menu.css?nrg18t");
@import url("http://mysite.co.uk/sites/all/modules/admin_menu/admin_menu.uid1.css?nrg18t");
@import url("http://mysite.co.uk/sites/all/modules/admin_menu/admin_menu_toolbar/admin_menu_toolbar.css?nrg18t");
</style>
<style type="text/css" media="all">
@import url("http://mysite.co.uk/sites/all/modules/colorbox/styles/default/colorbox_style.css?nrg18t");
@import url("http://mysite.co.uk/sites/all/modules/ctools/css/ctools.css?nrg18t");
@import url("http://mysite.co.uk/sites/all/modules/seo_checklist/seo_checklist.css?nrg18t");
@import url("http://mysite.co.uk/sites/default/files/custom-css.css?nrg18t");
@import url("http://mysite.co.uk/sites/all/modules/devel/devel.css?nrg18t");
</style>
<style type="text/css" media="all">
<!--/*--><![CDATA[/*><!--*/
#sliding-popup.sliding-popup-bottom{background:#B81007;}#sliding-popup .popup-content #popup-text h2,#sliding-popup .popup-content #popup-text p{color:#ffffff !important;}
/*]]>*/-->
</style>
<style type="text/css" media="all">
@import url("http://mysite.co.uk/sites/all/modules/eu_cookie_compliance/css/eu_cookie_compliance.css?nrg18t");
@import url("http://mysite.co.uk/sites/all/modules/widgets/widgets.css?nrg18t");
</style>
<style type="text/css" media="all">
@import url("http://mysite.co.uk/sites/all/themes/business/style.css?nrg18t");
@import url("http://mysite.co.uk/sites/all/themes/business/color/colors.css?nrg18t");
</style>
Comments
Comment #1
bigmonmulgrew commentedComment #2
mkalkbrennerSeems like we have to add support of group and weight options to Themkey CSS according to https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_ad...
Comment #3
loparev commentedComment #4
loparev commentedHi. This patch should resolve this issue.
Comment #5
loparev commentedForgot new line at end of the *.install file
Comment #6
loparev commentedO, come on! One more patch :D
Comment #7
loparev commentedComment #8
bigmonmulgrew commentedPatched #6 and it now works, thanks a lot for your help.
Comment #9
mkalkbrenner@bigmonmulgrew:
It would be great if you can give something back by just writing a few lines how to use the feature and add them as a sub page to https://www.drupal.org/node/2145521 . And a screenshot would be great.
Comment #10
mkalkbrenner@Loparev: First of all, great work! The patch already looks very good.
I'm not sure about this. I will have a closer look and think about it again before committing it.
We should shorten the displayed string. What about this?
To make the patch even better we should add at least a small test that checks the addition of css files at the right position. I assume this test is straight forward if you look at the existing ones. Just create a rule that adds any css file that already exists somewhere in core.
Finally another feature that would be nice to have but is not a must: I think it would nice to be able to optionally show the list of css files and their order on the current page within ThemeKey Debug using drupal_get_css(). That would ease debugging if css aggregation is turned on.
Comment #11
loparev commentedAdded short css_group_options and patched ThemeKey Debug. Now it can optionally show list of css files on a page.
Comment #12
loparev commentedComment #13
bigmonmulgrew commented@mkalkbrenner Planning to do just that once I've got to grips with themekey a little more
@Loparev regarding #11 can you clarify a little please. you said can optionally list css files on a page. I'm viewing all the enabled css files by using firefox built in style editor. Other than thi sI can't see a way to list the css files?
Comment #14
loparev commented@bigmonmulgrew, you need to enable ThemeKey Debug module. Then on admin/config/user-interface/themekey/settings/debug you should check "Show list of css files" checkbox. After that at the bottom of every page will be block with css debug message.
Comment #15
loparev commented@bigmonmulgrew, all works as expected?
Comment #16
bigmonmulgrew commented@Loparev
Yes its working as intended. It appears some themes have a quirk in the css weights, sometimes it works fine with default settings, sometimes its required to set it to group, theme, weight 50, but ultimately it work brilliantly. Very very useful. I'd guess its something to do with how the theme applies and weights the css files.
If you would like to see what I've done with it check out stanspals.co.uk. Its based on the business theme https://www.drupal.org/project/business
Thanks so much for your help
Comment #17
bigmonmulgrew commented@mkalkbrenner i have written a quick how-to on what I did, hope its up to your standards
Comment #18
mkalkbrennerThe detailed description should be moved to the leading comment block of function
themekey_debug_filter_css_array($element)This should be moved to themekey_css.module and implemented as
themekey_css_themekey_debug_settings_form_alter()to only display this option if themekey_css is enabled.In addition themekey_css_uninstall() has to call
variable_del('themekey_debug_show_css_files').To respect the namespace a better variable name would be themekey_css_debug_css_files.
Comment #19
mkalkbrenner@bigmonmulgrew: we don't have a standard right now and any piece of documentation we can get is great :-)
I had a quick look at https://www.drupal.org/node/2536930
I think your example could be improved. For such use cases we have a special property that is evaluated quicker than user:uid. Just use
system:dummy = dummy.BTW did you read the tutorials that are included in the module? To see them you need to enable core's help module. I think we should "copy" these tutorials to the handbook on drupal.org.
Comment #20
loparev commented@mkalkbrenner, done.
1.
3. I think we should delete 'themekey_css_debug_css_files' variable in hook_disable. Because if user selected 'Show list of css files' checkbox on debug settings form and then he disabled themekey_css then 'Show list of css files' checkbox will disappear from debug settings form but css debug message will not disappear. So we don't need call variable_del('themekey_css_debug_css_files') in hook_uninstall because this variable will be deleted in hook_disable.
Comment #21
loparev commentedComment #22
mkalkbrennerIt's easier to review an interdiff between #11 and #20.
Comment #23
mkalkbrennerThat's a good argument to delete the variable in hook_disable instead of hook_uninstall!
But we should move the comment into the function. Otherwise it will occur in the API documentation and it's only about internal information.
According to the drupal coding standards these comments must not exceed 80 characters per line.
I hope to find some time to provide a simple test for this patch soon and then we can commit it :-)
(Within the ThemeKey project I'm a bit more restrictive because of more than 20,000 installations.)
Comment #24
loparev commentedComment #25
loparev commentedFinal changes
Comment #26
mkalkbrennerUnfortunately we're not done yet :-(
Unless today I just looked at the code, because Drupal 8 core occupied most of my time. But now I applied the patch a gave it a try. I found a major issue: table drag isn't working anymore on the CSS rule chain!
css class names should avoid some characters. Somewhere in core there's a function to generate css class names from a given value. For example it converts '_' to '-'.
As I already mentioned earlier in #10 this looks suspicious to me. Right now I noticed that the table drag feature is broken! The parent item is not hidden anymore and the table structure modified via drag & drop is not saved. Core's table drag feature requires parent and weight!
See function theme_themekey_abstract_rule_chain_form():
Comment #27
loparev commentedHi!
This patch resolves problem with table drag&drop. I tested it and for now it's works.
I just remove parent and weight from header for "New item" table. Just like in your code you set up header only with 3 first values ("ADDING CSS RULE CHAIN", "CSS FILE" and "ENABLED"). There was no "parent" and "weight" in table header.
Try this patch please.
Comment #28
loparev commentedComment #29
bigmonmulgrew commentedI've just tested it and table drag is now working.
Everything else seems to be working fine as far as i can tell.
Comment #30
bigmonmulgrew commentedSlight issue found. At the bottom of my status report page I've got Array- Array. Not sure if its caused by this. I've made other changes., Just gonna do some digging and see whats what
Comment #31
loparev commentedI will check it on clean drupal installation.
Comment #32
loparev commentedThere is no problems with status report page on clean installation.
Comment #34
mkalkbrennerCommitted to git. Thanks a lot for the work!