Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions

Current best method for including print.css


5 Posts   2783 Views

Samba Sam

23 October 2009 at 10:39pm Community Member, 85 Posts


Looking through the archives, I came across a suggestion for appending a print.css to a template by adding the following to your Page_Controller -> init method:

Requirements::themedCSS("print.css", "print")

However in the default Page.php document. it says the following.
// Note: you should use SS template require tags inside your templates

Is there one for the current version of SS for print.css? What is the current best method for including a print.css?



24 October 2009 at 12:31am Forum Moderator, 5511 Posts

That is still currently the best way. I don't think <% require %> in templates support media types (such as print yet)

Samba Sam

25 October 2009 at 8:52am Community Member, 85 Posts

Hi Will,
Thanks for your quick response. But I can't seem to get your suggestion to work.

I added Requirements::themedCSS("print.css", "print") to Page.php, as in the following:

class Page_Controller extends ContentController {
   public function init() {
      Requirements::themedCSS("print.css", "print");

I refreshed the database, yet their is no linked print. css code in the head of the index file when I go to view the

I'm I missing something?



25 October 2009 at 10:54am Forum Moderator, 5511 Posts

themedCSS will add the .css for you. Just try Requirements::themedCSS('print', 'print');

Martin D.

17 October 2013 at 7:05am Community Member, 21 Posts

In case you are still wondering, the method looks like this:

Requirements::themedCSS('printstylesheet', null, 'print');