Hey everyone : )
I'm working on a new theme for Moodle 2 at the moment; and I was wondering if anyone can please point me in the right direction regarding an enhancement I want one of my layouts to have?
Background/reason for enhancement:
We have a lot of academics at our institution who like to have a banner image in their course site.. it causes some huge consistency problems, they take up way too much screen space, and most of them repeat the course name and course code!
To save space, and reduce information redundancy I want to allow them to upload a picture in their course topic, which the course layout file then incorporates IN to the moodle banner.
What I've done:
I'm not exactly sure about the best approach, and I'm by no means an experienced OO programmer or even that experienced with PHP and the moodle back-end.. but, this is what I have so far.. it's half hard-coded, but it does work. The digit 71 must be the row number of the file in the DB right? I'm not sure how on earth I can go about parameterising this part, or even if I'm close or on the right track.. I'm out of my depth when it comes to having to query the DB to find the corresponding ID...
<?php
global $CFG;
$context = get_system_context();
$file = $CFG->wwwroot . '/pluginfile.php/71/mod_resource/content/' . $context->id . '/banner.png';
echo "<div id='customBanner' style='opacity: 0;'><img src='http://moodle.org/'" . $file . "' alt='Course banner' /></div>" ;
?>
btw, the opacity style is to do with some YUI3 effects I have; I'm also fading the image in after fading out the institution's logo.
Is the pluginfile.php even the right direction? Or is there a MUCH better way to do what I want?
I'll attach a screeny too. In the screenshot you can see what I mean, I've uploaded the banner.png file in the course topic area; the code above has then just rendered it in to the actual moodle banner
Any advice at all will be appreciated sooooo much.
Thanks
Rolley