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 forum.silverstripe.org 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.

Archive /

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

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

Default CSS files


Go to End


5 Posts   2325 Views

Avatar
jam13

121 Posts

21 September 2007 at 4:55am

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.

Avatar
Sigurd

Forum Moderator, 628 Posts

21 September 2007 at 11:55am

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)

Avatar
jam13

121 Posts

21 September 2007 at 8:47pm

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.

Avatar
Ingo

Forum Moderator, 801 Posts

22 September 2007 at 1:14am

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.

Avatar
jam13

121 Posts

25 September 2007 at 8:19am

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.