10448 Posts in 2223 Topics by 1719 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 306 Views |
-
Requirements:: in silverstripe-mobile Module Problem

16 February 2012 at 11:55am
Just thought I would make an observation that if one has this in page.php:
Requirements::themedCSS('layout');
Requirements::themedCSS('typography');
Requirements::themedCSS('form');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?
Julian
-
Re: Requirements:: in silverstripe-mobile Module Problem

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()) {
Requirements::css("your/mobile.css");
}
else {
Requirements::css("your/plain.css");
}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.
-
Re: Requirements:: in silverstripe-mobile Module Problem

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:
https://github.com/silverstripe/silverstripe-mobile/pull/38
Usage would be:
if($this->requestedMobileSite()) {
Requirements::css("your/mobile.css");
} else {
Requirements::css("your/fullsite.css");
}
| 306 Views | ||
|
Page:
1
|
Go to Top |


