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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

CMS references css files differently on production server

Go to End

3 Posts   1344 Views


Community Member, 8 Posts

1 August 2012 at 12:44pm

Edited: 01/08/2012 12:48pm

For some reason the CMS on our production server does not load the main, content panel correctly. When you first load up Pages, it is blank. Using Firebug, I noticed that it was loading many files via ajax in production that it wasn't on our development server.

Besides a ping, Dev just loads these two:


I then realized it is doing so because the <link> tags that bring in the CSS are referencing the files differently in production. Basically, they are missing the first forward slash in the href path, and so they are not loading the CSS files.

For example, this is wrong:

<link rel="stylesheet" type="text/css" href="framework/admin/thirdparty/jquery-notice/jquery.notice.css?m=1340880397" />
<link rel="stylesheet" type="text/css" href="framework/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css?m=1340880400" />

This is right:

<link rel="stylesheet" type="text/css" href="/framework/admin/thirdparty/jquery-notice/jquery.notice.css?m=1340880397" />
<link rel="stylesheet" type="text/css" href="/framework/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css?m=1340880400" />

Now, the really strange thing is that for some reason the following code causes it to load the files correctly, and I see no reason that it should. In the course of investigation I added this to the bottom of SSViewer::process():

     foreach($m as &$a){

I've attached two images. The first shows the problem - a blank panel. The second shows the panel loading the data correctly, with the debugging output. Makes no sense to me, so I was hoping to use the forum as a sounding board. Any ideas?

Attached Files

Community Member, 8 Posts

1 August 2012 at 1:05pm

In fact, outputting any character before the DOCTYPE

.<!DOCTYPE html>

causes it to reference the css files correctly, and thus load correctly.


Community Member, 8 Posts

1 August 2012 at 5:33pm

Edited: 01/08/2012 5:40pm

Maybe if I put it another way, someone can see where the problem lies...

In Requirements::includeInHTML(), this builds the <head> css file links

                        foreach(array_diff_key($this->css,$this->blocked) as $file => $params) {  					
				$path = $this->path_for_file($file);
                                //this always looks correct, starting "/framework/..."
				if($path) {
					$media = (isset($params['media']) && !empty($params['media'])) ? " media=\"{$params['media']}\"" : "";
					$requirements .= "<link rel=\"stylesheet\" type=\"text/css\"{$media} href=\"$path\" />\n";

But when I view the source after the page is built, the link's href is as follows:

<link rel="stylesheet" type="text/css" href="framework/admin/thirdparty/jquery-notice/jquery.notice.css?m=1342411329" />

How the hell does it start "framework" now without the forward-slash??? ANd how does screwing up the doctype by adding a character before it fix the path? That shouldn't be able to change the markup??? The browser doesn't seem to matter, tested so far in Firefox, Safari, Chrome.