Graphics, Images, Themes not working (pic and details inside)

Graphics, Images, Themes not working (pic and details inside)

by White Lights Owner -
Number of replies: 17

I installed Moodle on a new domain. I use Deluxe Hosting from GoDaddy. Everything seems to be functioning fine, but the themes and images are finnicky. When I first switch themes, the page appears as it is supposed to do. If I reload the page, much of the graphics disappear and the formatting is messed with. Here is a before and after:

Before/After

And here my config.php file that may be of use:

$CFG->wwwroot = 'http://www.whitelightslearning.com/moodle';

$CFG->dirroot = '/home/content/w/h/i/whitelights/html/moodle';

$CFG->dataroot = '/home/content/w/h/i/whitelights/html/moodle/data';

$CFG->admin = 'admin';

$CFG->directorypermissions = 00777; // try 02777 on a server in Safe Mode

require_once("$CFG->dirroot/lib/setup.php");

// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,

// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.

?>

Now, I'm not sure if my dirroot and my dataroot are correct. This is what was filled in when I installed Moodle. I copied the Moodle file to my server's directory. There is no home/content/etc. that I can see in my FTP or anywhere else. If anyone can help, I will owe them a cocktail. Thank you for your time.

Average of ratings: -
In reply to White Lights Owner

Re: Graphics, Images, Themes not working (pic and details inside)

by Chris Lamb -

From the look of the paths given in dirroot and serverroot I think this might be running on a Linux system, which puts me at a disadvantage as I know nothing about Linux!

What I would say is that you probably won't see folders called home, content, etc when you connect via FTP, because your service provider will have set things up so that you only see your own site not every site they're hosting, so you'll be coming into the path a bit further down, so what you'll see as your FTP 'root' directory will actually be a sub-directory on the server.  At a guess, what you're seeing as your FTP 'root' folder is probably the 'whitelights' folder in the dirroot path.  Have you got folders called HTML or Moodle when you connect via FTP?

Do your themes work at all once you've reloaded the page, or only when you're actually in the 'change theme' section?  If they work intermittently then your paths should be right, because if they were wrong it would never find them.  If they never work once you're out of the 'change theme' section then it could well be a path problem.

HTH

Chris

In reply to White Lights Owner

Re: Graphics, Images, Themes not working (pic and details inside)

by bill sparks -

I have exactly the same problem - I installed moodle on the weekend on Go Daddy - and my themes disappear as well?

Everything is white?

Have you resolved this problem?

lots of questions

In reply to White Lights Owner

Re: Graphics, Images, Themes not working (pic and details inside)

by Urs Hunkler -
Picture of Core developers

Hi White Lights Owner and Bill,

I never heard about a problem like yours. When you both have the same problem with the same ISP I suppose you have a problem with your server.

From the outside via this forum it is nearly impossible to help you when there are server or Apache rewriting or file access problems. Please try to check with your ISP how to get your Moodle installation working.

Sorry that I am not able to help you on
Urs

In reply to White Lights Owner

Re: Graphics, Images, Themes not working (pic and details inside)

by S. Lupo -
Hi there!
I've got exactly the same problem and I found out what causes it!
On my server I can choose whether I want to run my php-script with php5 or with php4. If I choose php4 I can reload the pages as often as I want and their are always shown fine. But if I choose php5 I have the same problem you mentioned! It seems that the Moodle Themes are not fully php5 compatible...  But  I've got no clue why...
Any suggestions?

warm regards
  Sandro

In reply to S. Lupo

Re: Graphics, Images, Themes not working (pic and details inside)

by White Lights Owner -

Sandro,

I contacted GoDaddy about this and they said that the server should read the php4 fine. My plan states that there is php4 and php5. How did you go about choosing php4? Still having trouble sad

In reply to White Lights Owner

Re: Graphics, Images, Themes not working (pic and details inside)

by Robert Saari -
You will have to contact your GoDaddy Administrator and ask them to configure the server to run the version of PHP that you want. 
In reply to White Lights Owner

Re: Graphics, Images, Themes not working (pic and details inside)

by Robert Saari -

After switching themes, open your web browser and clear the history and temporary internet files.  This solved the problem for me.

In reply to White Lights Owner

Re: Graphics, Images, Themes not working (pic and details inside)

by James Ballard -
Did you delete any themes from your folders. We messed up our themes by trying to tidy up the themes folder and deleted the standard theme that comes with Moodle. Took us a while to find this out but re-uploading the standard theme fixed it for us.
In reply to James Ballard

Re: Graphics, Images, Themes not working (pic and details inside)

by S. Lupo -
the problem occures only running php 5. Therefore it can not be caused by a messed up theme. My hoster runs php4 as default. If I want to run php5 I have to put a file named .htaccess in the directory where the php-files are located.
The file contains the following line:
AddHandler x-httpd-php5 .php

This settings affects any php file in this and any sub-directories. Probably this dual mode cause the problem... Because running the same moodle-installation on my development server, everyting works fine... But nevertheless in my opionen, the moodle files have a bug, because other websites using php5 work all fine... I can reload the page as often as I want, the images are always shown...


UPDATE:
As I had the impression that the page looks like missing the css-file after reload, I tried to access directly the css-file and I made an interesting discovery! The first time I access the file (for example www.mymoodlebalabla.com/themes/standard/styles.php ) I get the file. The second time I get the following error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, XXXX@XXX.ZZ and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

After a next reload I can access the file again. But the fourth fails... So every second file access fails.... I will go further into this matter and post my results here.
In reply to White Lights Owner

SOLUTION!!

by S. Lupo -
I got it! big grin
Comment out line number 2044 in "yourmoodledir/lib/weblib.php" and the problem is solved!

But now it would be interesting to know, why the last-modified field in the header causes this problem.....

UPDATE:
Even my suggestion above solves the problem, it's not the real place where the error occures! Each theme has a file called 'styles.php' the last command in this file calls the following function:
style_sheet_setup(filemtime('styles.php'), $lifetime, $themename, $forceconfig, $lang):

As the first parameter (the filetime) is used for the last-modified header field, I found out, that this function (filemtime) is responsible for the crash afterwards. Replacing the first parameter with time() fixes the problem. But there is still something wrong... because calling filemtime and then stop the script (with die;) works even if I reload the page several times... ?!! mixed
Average of ratings: Useful (1)
In reply to S. Lupo

Re: SOLUTION!!

by David Scotson -

Maybe I'm missing something, but according to that code snippet, the file 'styles.php' is asking for the time of the last change to the file called 'styles.php' (that is, itself). But that file also has at the top a comment saying:

THERE SHOULD BE NO NEED TO MODIFY THIS FILE!! USE CONFIG.PHP INSTEAD

So even if it's not causing the crashing, surely that's a bug as the lastmodified time of the stylesheet will always be wrong.

In reply to David Scotson

Re: SOLUTION!!

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Yes, that looks like a typo. At least it should have been config.php.

I've changed it to be the current time() in all themes in HEAD.
In reply to Martin Dougiamas

Re: SOLUTION!!

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I have only been following this very vaguely and I might be missing something, but why is this all so complicated?

Correct me if I'm wrong but all the styles in the selected theme cascade from the standard theme. So... why not simply generate a big list of CSS includes in the header. Whatever .css files you find in the standard theme followed by all the modules and blocks (surely these can be .css not .php) and then the .css in the selected theme.

You end up (potentially) with a very big list of css links in your header, but so what? They will be cached by the browser and/or your proxy. This also gets all the php out of the themes, which must be a good thing.
In reply to Martin Dougiamas

Re: SOLUTION!!

by David Scotson -

I think the original typo might actually be better (if it's not the cause of these crashes). Having looked into it, there's code within style_sheet_setup which looks like it compares the lastmodified time with the lastmodified time of each of the .css files it reads in from the theme.

Therefore an incorrect but old time (e.g. 0) is better than an incorrect but newer time (e.g. right now) as it will get overwritten with a newer, and more correct time anyway.

But, having said that, it appears that that code isn't working as it should. I've just looked at a site that was set up on the 24th of last month, with a new .css file created and added to the theme a few days later. I can see my new CSS when I access styles.php and yet the last modified time is still the 24th. So something odd is going on.

In reply to David Scotson

Re: SOLUTION!!

by mark zuber -
Hi All.

I also have disappearing themes problem - I installed moodle on GoDaddy.  I tried php5 and php4 but it doesn't help.

S. Lupo has said that the solution is to "Comment out line number 2044 in yourmoodledir/lib/weblib.php. Can you tell me what line, I can't find line 2044 and what do you mean to "Comment out"?

Martin said   " ....I've changed it to be the current time() in all themes in HEAD. "   Can you clarify what did you change and was this change need to fix disappearing themes problem?

Mark

In reply to mark zuber

Re: SOLUTION!!

by S. Lupo -
Hi Mark,
forget what I wrote about commenting out a certain line in weblib.php.
As I mentioned later, I suggest that you alter the function call (style_sheet_setup) in styles.php of your used theme to the following:

style_sheet_setup(time(), $lifetime, $themename, $forceconfig);

This works perfect for me!
Regards
Sandro
In reply to S. Lupo

Re: SOLUTION!!

by mark zuber -

Hi Sandro.

" style_sheet_setup(time(), $lifetime, $themename, $forceconfig);  " -works very well with php5 and php4 on godaddy.com.

Thank you.

Mark