Theme not displaying (new installation)

Theme not displaying (new installation)

by Noah A -
Number of replies: 13

Hi, I just installed the latest stable version of Moodle from git. I can navigate to the site, but there is no styling or images whatsoever. My javascript console shows that I'm getting 404 errors on several theme-related resources. The URL is as I would expect, it's not localhost. Any suggestions?

Thanks.

Attachment MoodleErrorsObfuscated.png
Average of ratings: -
In reply to Noah A

Re: Theme not displaying (new installation)

by Usman Asar -
Picture of Plugin developers Picture of Testers

Noah,

depending on theme, few resources are fetched from CDN (specially in bootstrap based themes), so may not work on localhost, whilst works on live servers.

In reply to Usman Asar

Re: Theme not displaying (new installation)

by Noah A -

If you read it again, you'll find that I said it was not localhost. It's hosted from an internet-accessible VPS. Any other ideas? smile

In reply to Noah A

Re: Theme not displaying (new installation)

by Luis de Vasconcelos -

Noah,

Do you experience this theme rendering problem on the Moodle front page, or only when you go into that course? Do you experience it in ALL your courses, or just this one course?

And does it only happen when you use the Clean theme? Or does it also happen with other themes?

I think MDL-47645 is related to this problem.

In reply to Luis de Vasconcelos

Re: Theme not displaying (new installation)

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Luis,
here the HTTP 404 errors are related to the incorrect PATH_INFO support i.e. the server hosting the Moodle instance does not honor the so called Moodle slash arguments.

@Noah, please, disable the Moodle slash arguments accessing the Moodle database, precisely the mdl_config table: there, you'll find a record for the slashargument configuration parameter => change its value from 1 to 0. Remember that some modules require this configuration, e.g. the SCORM module: IMHO it is wiser to change the hosting package or... the provider ;).

HTH,
Matteo

Average of ratings: Useful (1)
In reply to Matteo Scaramuccia

Re: Theme not displaying (new installation)

by Luis de Vasconcelos -

Mateo,

Thanks. How did you work that out? smile

Wouldn't it be better to disable slasharguments through the option under Site administration / Server / HTTP instead of changing it in the database?

Or adding $CFG->slasharguments = false; in the Moodle config.php file?

In reply to Luis de Vasconcelos

Re: Theme not displaying (new installation)

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Luis,
if you already know the Moodle interface - no beauties here due to the lack of the CSS files - it could be easy to disable it being logged in as the administrator; otherwise, you could hack the config.php file using $CFG->slasharguments = 0 or, better, to change it on the database - as explained above - to be able to still configure it from the WebUI in the future.

The key point here is that having PATH_INFO not supported is not a wise server configuration choice, regardless the PHP web app you want to deploy.

Receiving an HTTP 404 on a Moodle URL containing a PHP file whose scope is "to serve a file" (described in the PATH_INFO) is the key to understand the lack of the slash arguments support, e.g. in javascript.php/1417038529/lib/javasctipt-static.js the PHP file is designed to serve the PATH_INFO provided after, 1417038529/lib/javasctipt-static.js, where 1417038529 is the timestamp of the last theme cache purge (Moodle update/upgrade or a new theme i.e. it is a mechanism to force browser cache update on each code/theme change) and lib/javasctipt-static.js is the real file Moodle should provide to the browser.

Mine is actually a guess: the OP could explore each request and read the body of the HTTP 404 response where Moodle should write the reason for that error.

HTH,
Matteo

In reply to Matteo Scaramuccia

Re: Theme not displaying (new installation)

by Noah A -

Thank you all for your help! The first thing I tried was to change the value in the SQL database, as you suggested. That didn't work. (It didn't even change the value shown in the webinterface, as I confirmed after it was in a usable state). What did work is this answer: http://stackoverflow.com/a/17107232 (configuring nginx to allow for slasharguments). Thanks for pointing me in the right direction!


BTW, I got locked out of my account somehow, that's why I have a different username.

In reply to Noah A

Re: Theme not displaying (new installation)

by Luis de Vasconcelos -

It's scares me that slasharguments can break Moodle like this...

In reply to Luis de Vasconcelos

Re: Theme not displaying (new installation)

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Luis,
it prevents the loading of some CSS files and maybe some JS files and than the WebUI is broken due to the missing of those expected files.
When Moodle doesn't use slash arguments - except for some module like SCORM which requires it otherwise the SCORM content serving will be broken - it should use an HTTP GET param like file or jsfile to pass back what should be the file to be served.
Using a proper set of URL rewriting rules will always "fix" this issue regardless what Moodle should do to properly fall back.

That being said, there could be an issue - read: a bug - when slasharguments is off and Moodle doesn't fall back to the HTTP GET param. We could use your issue in the Tracker to point to this discussion and you could test a Moodle instance - running on Windows or Linux, it doesn't matter - to look for Moodle being able to fall back as expected by looking at the URLs being called by your browser.

HTH,
Matteo

In reply to Matteo Scaramuccia

Re: Theme not displaying (new installation)

by Luis de Vasconcelos -

Thanks Matteo.

What URL rewriting rules should be used (for Windows / IIS)? Searching this forum and MoodleDocs leads to a few different rules - but no thorough explanations of them.

In reply to Usman Asar

Re: Theme not displaying (new installation)

by Luis de Vasconcelos -

Usman, are you saying that Moodle servers have to be internet facing? That sounds crazy! That would imply that you can't run those themes on an intranet. Or at a rural school in a poor country where internet access is not available...

I doubt the founder and creator of Moodle would allow Moodle Themes to go that way, considering that he himself grew up in a small rural settlement in Australia where there was no internet access, so he is quite familiar with the challenges facing poorer schools.

I've run bootstrap themes on my test servers (which aren't internet facing) and they have worked. I've never analyzed the network traffic to see if they do try to access any external CDN's, but it's never been a problem. So, can you explain further why those themes won't work on localhost.

I haven't tested many themes recently, apart form the core themes in Moodle. Are you referring specifically to non-core themes?

In reply to Luis de Vasconcelos

Re: Theme not displaying (new installation)

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Luis,
Husman is right: it could depend on the theme code design and/or its configuration and... - some rare times ;) - on Moodle bugs, e.g.: MDL-42679, MDL-36334.

HTH,
Matteo