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


Reply


5 Posts   2893 Views

Avatar
Samba Sam

Community Member, 85 Posts

23 October 2009 at 10:39pm

Hi,

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?

Thanks,
Sam

Avatar
Willr

Forum Moderator, 5513 Posts

24 October 2009 at 12:31am

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

Avatar
Samba Sam

Community Member, 85 Posts

25 October 2009 at 8:52am

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() {
      parent::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 page.ss.

I'm I missing something?

Sam

Avatar
Willr

Forum Moderator, 5513 Posts

25 October 2009 at 10:54am

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

Avatar
Martin D.

Community Member, 21 Posts

17 October 2013 at 7:05am

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

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