Jump to:

10929 Posts in 2613 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Requirements:: in silverstripe-mobile Module Problem

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 457 Views
  • tazzydemon
    Avatar
    Community Member
    120 Posts

    Requirements:: in silverstripe-mobile Module Problem Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Requirements:: in silverstripe-mobile Module Problem Link to this post

    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.

  • kinglozzer
    Avatar
    Community Member
    138 Posts

    Re: Requirements:: in silverstripe-mobile Module Problem Link to this post

    ** 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");
    }

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