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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

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

Requirements:: in silverstripe-mobile Module Problem

Go to End

3 Posts   815 Views


Community Member, 135 Posts

16 February 2012 at 11:55am

Just thought I would make an observation that if one has this in page.php:


This this is called before the theme switch onAfterInit in silverstripe-mobile and thus you get the unwanted main theme css in the mobile theme

The fix is simple, move the requirements to the template... but this is deprecated, so what's the official view?



Forum Moderator, 5523 Posts

20 February 2012 at 7:51pm

The fix is simple, move the requirements to the template... but this is deprecated, so what's the official view?

Including it in the template is not deprecated by any means, the only issue is the template API provides a much smaller set of functionality to the PHP requirements API (e.g you cannot use combine_files())

In your case, I suggest you could do something like this in your Page.php init function.

if($this->onMobileDomain()) {
else {

If you're including multiple css files (i.e layout, type and form) perhaps take a look at Requirements::combine_files(), can help speed up a site by reducing http requests.


Community Member, 187 Posts

23 February 2013 at 1:05am

** Mega bump **

I've just been having this trouble, and can't use onMobileDomain() as the site doesn't have a mobile domain. I've written a solution that appears to work perfectly for me, submitted a pull request:

Usage would be:

if($this->requestedMobileSite()) {
} else {