Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » Current best method for including print.css

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2613 Views
  • Samba Sam
    Avatar
    Community Member
    85 Posts

    Current best method for including print.css Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Current best method for including print.css Link to this post

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

  • Samba Sam
    Avatar
    Community Member
    85 Posts

    Re: Current best method for including print.css Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Current best method for including print.css Link to this post

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

  • Martin D.
    Avatar
    Community Member
    20 Posts

    Re: Current best method for including print.css Link to this post

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

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

    2613 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.