When the print view is accessed in the Chrome browser, the recipe_html.css file is not being applied. This does not appear to be a problem in Firefox or IE9. I checked into the problem and saw that the @import url() statement is missing a semicolon at the end. Adding it to the statement definition in recipe_html.module's template_preprocess_recipe_html_page() fixes the problem.
Also, when I set up a new test site for creating the patch I ran into another problem where the stylesheet wasn't being applied on any browser. The URLs aren't being made absolutely web-accessible by running them through file_create_url(). This code from drupal_pre_render_styles() is used to write the @include statements during normal template processing:
$import[] = '@import url("' . check_plain(file_create_url($item['data']) . '?' . $query_string) . '");';
Current template_preprocess_recipe_html_page() style definition:
$variables['styles'] = '<style type="text/css" media="all">@import url("/' . $css_path . '")</style>';
Proposed:
$variables['styles'] = '<style type="text/css" media="all">@import url("' . check_plain(file_create_url($css_path)) . '");</style>';
Patch to follow.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 1541498-recipe-print-view-css-not-applied-in-chrome-4.patch | 861 bytes | jvandervort |
| #3 | 1541498-recipe-print-view-css-not-applied-in-chrome-3.patch | 861 bytes | jvandervort |
| #1 | 1541498-recipe-print-view-css-not-applied-in-chrome-1.patch | 890 bytes | dcam |
Comments
Comment #1
dcam commentedThe patch modifies recipe_html.module to include the proposed solution.
Comment #2
dcam commentedComment #3
jvandervort commentedCan you try this one? The check_plain() and file_creat_url() should be unnecessary.
Comment #4
jvandervort commentedOops, I mean this one.
Comment #5
dcam commented#4 fixed the problem Chrome-exclusive problem that I was initially trying to solve.
The reason the second problem was occurring is because the site root of the new test site I created is at localhost/drupal7. The print view ends up telling my browsers to import the stylesheet from /sites/default/modules/recipe/includes which means browsers are for it in localhost/sites... and it can't be found.
I agree check_plain() isn't necessary. I questioned whether I should add it, but did anyway because drupal_pre_render_styles() does. file_create_url() makes the stylesheet's path absolute, fixing the problem for sites sitting in subdirectories. I think this could potentially happen to other people, but it may just be an unrealistic edge case. What do you think?
Comment #6
jvandervort commentedCommitted, thanks.
Comment #7.0
(not verified) commentedAdded the file name to the issue description.