Themes

Customisable watermark image as a kinda desktop image for your theme

 
Frankie's the name, Moodle's my game!
Customisable watermark image as a kinda desktop image for your theme
Group Particularly helpful MoodlersGroup Plugin developers

Hi

Here's the thing. We (almost) all like to customise our Windows XP/Vista/7/8 desktop with colourful and interesting images. Sort like an extension of our personality. So why not be able to personalise, from the front end of a Moodle coursepage, the watermark image of a coursepage?

I used the Mary Evans' watermark code to make a sort of desktop image for my theme. So the activities, blocks and content kinda 'float' on top of the background image. Something like a Blogspot blog. Some folk may not find it to their taste, but I think, for now, it's kinda cool. 

Demo:
http://www.moodurian.com/cefl/course/view.php?id=2
Username: ergo
Password: ergo

Give it a try, then scroll up and down the coursepage with your mouse (vertical scrollbar). Tell me if you like what you see..or loathe. smile



I'm using a theme named Ergo. Here's my take on this. I was wondering if there was a way for the user to use a frontend interface (mini form or an extra field) to upload his or her own image watermark (which is the background image). In this way, the theme remains the same for all users, but each user can customise their own 'theme desktop' which is essentially just a very large watermark image that gives the effect of a background image. The end I am trying to achieve is this. If a course theme overrode all user themes, then all users would use the same theme when accessing a coursepage. To spice it up more, each user is allowed to upload their own watermarl image file.  That would achieve the goal of each user personalising the same standard coursepage theme with a background image of their own. So for that coursepage that has a course theme set, all menus, blocks and buttons would look the same since use the same course theme (if the course theme is set) is being used, but each user can stamp their own individuality by using a separate watermark file. So the background image for Andy would be different from say, the background image of Belinda. But both would be using the same course theme! Hehehe. Whadya think? Any comments anyone?

Just thinking creatively to see where this railroad leads...cool
Frankie Kam

 

 
Average of ratings: -
It's only an avatar...
Re: Customisable watermark image as a kinda desktop image for your theme
Group Core developersGroup Documentation writersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Hi Frankie,

You should be able to do that by first creating a URL field in the User profile, and giving it a specific Short Name which you will need to use in your CSS. This then would allow a Student to add a url say from Flikr or some other source where they can link to an image and then that image would be used whenever that person logged in.

I did something similar in the Aardvark Post-IT theme, but I was added a URL to add an email link. such as: mail.yahoo.com or mail.google.com which showed up in the dropdown profile-block in that theme.

I will need to check this out to see if the same thing will work for an image.

EDIT: Just checked the PHP code I used looked like this:

 <a href="http://<?php echo $USER->profile['MailBox'];?>" >My Emails</a>
where $USER->profile['MailBox'] represents the shortname (I think that's what it was called?), so I am guessing that you can use something like this to call an image into your theme based on $USER->profile['background'] or whatever you choose to use as the shortname?

Cheers

Mary

 
Average of ratings: -
Picture of Richard Oelmann
Re: Customisable watermark image as a kinda desktop image for your theme
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers
That would work for images within the html/php Mary, but I don't think it works for images into css because of the caching - although whether we could now use the code that we have in settings pages to refresh the cache for a user, I'm not sure, but when I tried a while back to create a user profile based css setting I could only get it to work while theme designer mode was turned on. Maybe its time for me to revisit that idea and try it again - I know there have been a few requests/suggestions over the years for the ability to personalise in this way smile
 
Average of ratings: -
It's only an avatar...
Re: Customisable watermark image as a kinda desktop image for your theme
Group Core developersGroup Documentation writersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Hi Richard,

You should be able to do it using variables.

PHP

<?php $bgimage = $USER->profile['bgimage']; ?>

CSS:

body {
   background: url("<?php echo $bgimage; ?>") no-repeat;
}

I haven't tested it yet, but it should work.
You would need to add this directly to the layout page in the <head></head> and treat it as a CSS link

Cheers

Mary

 
Average of ratings: Useful (1)
Picture of Richard Oelmann
Re: Customisable watermark image as a kinda desktop image for your theme
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Ah thank you Mary - I had not considered the idea of adding it into <head> separate from the cached css  - great idea smile

I'll try it over the weekend if I get chance smile

 
Average of ratings: -
Gareth J Barnard
Re: Customisable watermark image as a kinda desktop image for your theme
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developers

Does not have to be in the 'head', Collapsed Topics since the beginning of time has included custom style within the 'body' (because a course format is loaded via the course main content mechanism): https://github.com/gjb2048/moodle-format_topcoll/blob/master/format.php#L110-L239

 
Average of ratings: Useful (1)
It's only an avatar...
Re: Customisable watermark image as a kinda desktop image for your theme
Group Core developersGroup Documentation writersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

There you go!

So it can be done!

 
Average of ratings: -
Picture of Richard Oelmann
Re: Customisable watermark image as a kinda desktop image for your theme
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Works perfectly with a text input custom user field

Hmmm - next reading up task: can the install routine of the theme add records to the mdl_user_info_field table and create the custom user profile fields automatically? Haven't previously used these kind of database features, but I'm sure its part of the db/install.php but need to read up more about that smile

 
Average of ratings: -