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.

General Questions /

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

Empty _config.php file breaks CMS / Website


Reply


5 Posts   4003 Views

Avatar
FullWebService

Community Member, 38 Posts

23 April 2011 at 11:48pm

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
Avatar
Willr

Forum Moderator, 5513 Posts

24 April 2011 at 12:37pm

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.

Avatar
FullWebService

Community Member, 38 Posts

24 April 2011 at 1:05pm

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.

Avatar
xeraa

Google Summer of Code Hacker, 58 Posts

18 May 2011 at 9:11am

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

Avatar
Martijn

Community Member, 271 Posts

19 May 2011 at 6:20am

I have the same thing..

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

<?php
//