Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Default CSS files

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1826 Views
  • jam13
    Avatar
    121 Posts

    Default CSS files Link to this post

    Is there any way of stopping SilverStripe from automatically adding the two default CSS files (layout.css and typography.css) to pages in the main site? I would prefer to be able to add the CSS links in manually in the page template or using a variable (like $MetaTags)

    Thanks,

    Jamie.

  • Sigurd
    Avatar
    Forum Moderator
    628 Posts

    Re: Default CSS files Link to this post

    Those CSS files have specific and smart meanings; for instance, typography.css is loaded into the CMS backend, so that you can have the site and the admin interface look identical. Additionally, we're trying to create conventions (not rules!) so that silverstripe sites can reuse themes, and reuse HTML/CSS, collaborate more easily with other people, etc.

    Do you mind explaining why you don't wish to use these? (Its useful to know what people are doing with SilverStripe so we can always make it better)

  • jam13
    Avatar
    121 Posts

    Re: Default CSS files Link to this post

    It's not that I don't wish to use them, I just don't like them being automatically added into the templates without any control - it seems to be the only thing that does get added in in this way.

    Although I'm a great fan of convention over configuration I also like to be able to turn things off or control them manually if necessary (my perl is probably showing). Maybe a configuration option to disable the automatic behaviour coupled with a variable ($StyleSheets for example) that could be used to place them in the template manually? I might have a go at it myself if it really bugs me .

    We've just started to use SilverStripe in some live projects, and I must say that overall I'm very impressed with it. The quality of the design and programming seems to be a lot better than many of the other PHP projects I've seen. My only gripes are that it has it's own templating language (rather than using an existing mature system like Smarty or just inline PHP), and the lack of hierarchical URLs (e.g. /category/group/item) which makes dealing with large numbers of pages a bit awkward.

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Default CSS files Link to this post

    class Page_Controller exends ContentController {
    function init() {
    parent::init();
    Requirements::clear()
    Requirements::css('mysite/custom.css');
    }
    }

    just be aware that you might break some stuff when clearing requirements,
    e.g. pagecomments (that need prototype/scriptaculous). you can also use clear() with a parameter to clear a specific requirement.

  • jam13
    Avatar
    121 Posts

    Re: Default CSS files Link to this post

    That's just what I was looking for. So I can disable the typography.css file like this:

    class Page_Controller extends ContentController {
    function init() {
    parent::init();
    Requirements::clear("mysite/css/typography.css");
    }
    }

    I really like the modularity of the code that I've come across so far - it's so refreshing to find a PHP project that's properly designed!

    Thanks.

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