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.

We've moved the forum!

Please use for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Possible to use Requirements::combine_files in theme files?

Go to End

2 Posts   1549 Views


Community Member, 44 Posts

13 July 2012 at 3:15am

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
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 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 if this is possible? Thanks.


Community Member, 44 Posts

21 July 2014 at 9:29pm

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.