Jump to:

23550 Posts in 19336 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » Possible to use Requirements::combine_files in theme files?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 406 Views
  • svandragt
    Avatar
    Community Member
    44 Posts

    Possible to use Requirements::combine_files in theme files? Link to this post

    I'm just starting my first SS site and I am adapting the simple theme that comes with SS3. I want to replace the 4 require themecss calls with a single Requirements::combine_files call, to minimize the amount of requests on my live site.

    It works when I add the following code to the Page_Controller init() method:

          // combine css files
          Requirements::combine_files(
             'all.css',
             array(
                THEMES_DIR . '/simple/css/reset.css',
                THEMES_DIR . '/simple/css/typography.css',
                THEMES_DIR . '/simple/css/form.css',
                THEMES_DIR . '/simple/css/layout.css',
             )
          );

    However there is a note there that says:
          // Note: you should use SS template require tags inside your templates
          // instead of putting Requirements calls here. However these are
          // included so that our older themes still work

    When I put the call directly in the Page.ss theme file however the site won't load.
    As I want to make sure I'm future proofing my learning is there any guidance on how I have to change the call when putting it in Page.ss if this is possible? Thanks.

  • svandragt
    Avatar
    Community Member
    44 Posts

    Re: Possible to use Requirements::combine_files in theme files? Link to this post

    I noticed this thread hasn't had any replies. For the uninitiated: you are better off to use the controller's init() method to add-in the code.

    406 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.