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.

Comments

dcam’s picture

The patch modifies recipe_html.module to include the proposed solution.

dcam’s picture

Status: Active » Needs review
jvandervort’s picture

Can you try this one? The check_plain() and file_creat_url() should be unnecessary.

jvandervort’s picture

Oops, I mean this one.

dcam’s picture

#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?

jvandervort’s picture

Status: Needs review » Fixed

Committed, thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Added the file name to the issue description.