Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Empty _config.php file breaks CMS / Website

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 3496 Views
  • FullWebService
    Avatar
    Community Member
    38 Posts

    Empty _config.php file breaks CMS / Website Link to this post

    I have an empty _config.php file in a widget folder. This seem to break the CMS and front end of the website. If I look at the source of the CMS everything seems fine, but when I look at how the code gets parsed by browers, it seems like it ends the head earlier than it should.

    I've included a screenshot wich shows some weird margin bug at the top of the screen and the code as seen by the browser.

    Attached Files
  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Empty _config.php file breaks CMS / Website Link to this post

    You should perhaps put at least a <?php line inside that file.

    The empty space will likely be occurring since you have white space after a ?> tag. This is why our coding conventions recommend against using ?> tags.

  • FullWebService
    Avatar
    Community Member
    38 Posts

    Re: Empty _config.php file breaks CMS / Website Link to this post

    Thanks for the reply!

    Tha's what I usually do, but then it injects the <?php in the first line of every page.

    /admin/EditForm/ gives a JavaScript error when saving a page.

    /admin/Editform now starts with:

    <?php$('Form_EditForm').getPageFromServer(1);
    $('Form_EditForm').loadActionsFromString('<input class=\"action delete\" id=\"Form_EditForm_action_unpublish\"

    etc...

    When I look at the source of the cms the doctype line now looks like:

    <?php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    It seems to treat the php code as regular text.

    When I close the tag again and put <?php ?> in the _config.php file, it doesn't show up in the source, but I get the same error as above because of the whitespace between the tags.

  • xeraa
    Avatar
    Google Summer of Code Hacker
    58 Posts

    Re: Empty _config.php file breaks CMS / Website Link to this post

    As a follow up: I ran into the same issue today.

    If I put "<?php" into the _config.php file of a module, "<?php" is added at the very start of every page, right before the doctype. As soon as I add a newline to the configuration file, everything works as expected.

    Not sure if this is a bug or the punishment for wrong usage, but it's definitely annoying and hard to debug...

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: Empty _config.php file breaks CMS / Website Link to this post

    I have the same thing..

    I solve it with adding a // on the second line:

    <?php
    //

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