3

I want to edit core/misc/print.css that the Book module is referencing, and I don't know how.

If I should move the print.css somewhere and load a new print.css in my theme.info, or is there another way make changes to the core/misc/print.css without changing core?

4

You don't need to edit any core file, to achieve what you are trying to do. Since you are talking of a theme, you just need to replace the template file used from the Book module. This is what done from the Stable theme, which has its own book-export-html.html.twig.

The only reference to the misc/print.css file is in book-export-html.html.twig; there isn't any core library with a reference to that file, and this makes things easier for a theme.
book-export-html.html.twig contains the following code.

  <head>
    <title>{{ title }}</title>
    {{ page.head }}
    <base href="{{ base_url }}" />
    <link type="text/css" rel="stylesheet" href="misc/print.css" />
  </head>

In the template file for your theme, you just replace it with the following, if you don't want to use any print.css file.

  <head>
    <title>{{ title }}</title>
    {{ page.head }}
    <base href="{{ base_url }}" />
  </head>

If you just need to use a different print.css file for your theme, then you can simply edit the file path, and provide your own CSS file.

  <head>
    <title>{{ title }}</title>
    {{ page.head }}
    <base href="{{ base_url }}" />
    <link type="text/css" rel="stylesheet" href="the_path_relative_to_the_theme_folder/print.css" />
  </head>
  • 1
    Yes, the whole html page including <head> is in one twig template, because the Book module bypasses the drupal theming level and returns the printed output directly in a response: return new Response($this->renderer->renderRoot($exported_book)); – 4k4 Apr 15 '17 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.