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.
Remove drupal_add_css() from book.module - use #attached instead.
Meta issue: #1839338: [meta] Remove drupal_set_*() drupal_add_*() in favour of #attached/response for out-of-band stuff
Comment | File | Size | Author |
---|---|---|---|
#11 | 2012526-11-remove-drupal_add_css.patch | 1016 bytes | mcjim |
#9 | 2012526-8-remove-drupal_add_css.patch | 1012 bytes | mcjim |
#3 | 2012526-3-remove-drupal_add_css.patch | 1008 bytes | mcjim |
#1 | 2012526-remove-drupal_add_css.patch | 2.07 KB | mcjim |
Comments
Comment #1
mcjim CreditAttribution: mcjim commentedRemoved drupal_add_css from template_preprocess_book_navigation().
CSS is #attached in three different places:
In book_node_view() for the navigation below the node.
In BookNavigationBlock twice, for the block shown on all pages and the block only shown on book pages.
Comment #2
mcjim CreditAttribution: mcjim commentedActually, scratch that. The CSS is not needed by the blocks at all. Re-rolling…
Comment #3
mcjim CreditAttribution: mcjim commentedRe-rolled. CSS is #attached only in book_node_view().
Comment #4
tstoecklerCode looks good. This needs manual testing, however, to verify that the CSS is still being applied in all cases.
Comment #5
ekl1773Steps taken to test:
However, when I go to edit a book page (but NOT an article) or view the outline, the following error appears above the edit box:
Comment #6
mcjim CreditAttribution: mcjim commentedThank for the thorough review!
I don't think those notices have anything to do with this patch (might even be related to #2012920: Add child page link in book navigation does not insert parent into book outline), but will check them out.
Comment #7
tstoecklerSo can someone reproduce the problem without the patch?
Comment #8
mcjim CreditAttribution: mcjim commentedRe-rolled patch to keep up with HEAD.
re: #5 and #7
I think it's something to do with caching.
Can you try this:
1) Pull latest changes.
2) Apply patch
3) Do a clean install (will need to remove sites/default/files/php and sites/default/files/config_*, first).
4) Test creating a book.
I've just done this and have no errors.
Comment #9
mcjim CreditAttribution: mcjim commentedDid that forgetting to upload the patch, thing…
Comment #10
ekl1773Yes, tested on clean copy of 8.x, aforementioned error exists irrespective of this patch.
Pulled, applied, wiped sites/default/files etc, tested as above.
Some CSS appears to have loaded, but book.theme.css throws a 404 error when selected in the resources tab and the elements report that they're drawing CSS from themes/bartik, which does not include the subelement selectors like "next" and "up."
Either needs re-rolling or it's me?
Comment #11
mcjim CreditAttribution: mcjim commentedAh, the 404 is explained by http://drupalcode.org/project/drupal.git/commit/2432c02 which moved the CSS.
Rerolled!
Comment #12
ekl1773Ok, that appears to work, book.theme.css loads, elements are displayed accordingly, tested with several content types. Ditto above, but additionally: success!
Comment #13
catchCommitted/pushed to 8.x, thanks!