Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » layout.css and typography.css always showing in source in new theme

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

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

Page: 1 2
Go to End
Author Topic: 18162 Views
  • danielbenedykt
    Avatar
    Community Member
    9 Posts

    layout.css and typography.css always showing in source in new theme Link to this post

    Hi

    I am building a new theme, so I created a new folder under 'themes'.
    Then I changed the _config.php file to point to the new theme. That all worked perfect.
    They I was having a 'light blue' background but I never set that background.
    I looked at the source code of the resulting HTML page and I found that there are 2 lines that are included there but I didn't write them:

    <link rel="stylesheet" type="text/css" href="cms/css/layout.css" >
    <link rel="stylesheet" type="text/css" href="cms/css/typography.css" >

    These lines magically appear in the source and they mess up my design.
    Why are they included and how can I remove them?

    Thanks

    Daniel

  • danielbenedykt
    Avatar
    Community Member
    9 Posts

    Re: layout.css and typography.css always showing in source in new theme Link to this post

    ok, found the problem, but I still don't understand why is developed that way.

    When I create a new theme the files layout.css and typography.css are kind of mandatory.
    If they are there, it takes the new files automatically.
    If they are not there, it takes the one from Silverstripe admin page.

    For me that doesn't make sense since the idea was to create a totally new theme.

    Daniel

  • Wojtek
    Avatar
    Community Member
    149 Posts

    Re: layout.css and typography.css always showing in source in new theme Link to this post

    ok, let me explain it:

    first, the files layout.css, typography.css and form.css are mandatory to standardize the creation of themes.
    What's more, the CMS uses the typography.css file to display the content correctly during the edition.
    If these files are not detected, the default ones are used - in fact, it's not about the css files but about the whole themes.

    It shouldn't be a problem to name your files layout.css and typography.css to make things easier, but if it is, just create empty files with such names and then no default styling will be used.

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: layout.css and typography.css always showing in source in new theme Link to this post

    Nothings fixed in the 'core' apart from editor.css - if you want to control the fonts / colors in the cms then you have to use a editor.css.

    In the current theme editor.css just @imports the typography css so we can have styles for the CMS only in editor.css. Styles for the CMS and front end in typography.css and styles for the front end in layout.css.

    But you have full control over how ever you want to do it in your theme!. You can even choose not to include the CSS as we have - Via a PHP method (Requirements::css()) - you could hard code them in the theme if you wanted to or call them style.css and mysite.css or whatever - just remember to edit the Requirements call in the page.php file

  • danielbenedykt
    Avatar
    Community Member
    9 Posts

    Re: layout.css and typography.css always showing in source in new theme Link to this post

    Hi wojtek, willr

    Thanks for the information. That will help me a lot.

    Regards

    Daniel

  • Tama
    Avatar
    Community Member
    130 Posts

    Re: layout.css and typography.css always showing in source in new theme Link to this post

    I'm mobilising a website so wanting to call typography.css and layout.css in a non-standard way. What code do I need to use to make sure they aren't automatically inserted into the page?

    I've tried the following code in /mysite/code/Page.php

    // Disable automatic inclusion of layout.css and typography.css
    Requirements::clear('/themes/mytheme/css/layout.css');
    Requirements::clear('/themes/mytheme/css/typography.css');

    Any help would be appreciated.

  • Ryan M.
    Avatar
    Community Member
    309 Posts

    Re: layout.css and typography.css always showing in source in new theme Link to this post

    Why not just comment out or delete the requirements call in Page.php to ensure they aren't included? If you started your site theme by copying the blackcandy one and changing it to fit your design, the Page.php file will have the typography and layout requirement calls inside it already.

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: layout.css and typography.css always showing in source in new theme Link to this post

    @tama - instead of clear() you would want to use block() in that case.

    18162 Views
Page: 1 2
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.