MoodleDoc

Life on the edge of the moodleverse

Banners block for moodle 2.3

As my moodle sites act as hubs for communication with our learning communities (staff, students and parents) and our front pages get roughly 5 hits per user per day, it is prime real estate for promoting events, courses and activities.
One of the ways we do this is through community contributed banners:


(Prototype on a live moodle 1.9 site)

I’ve just released to github the source for a moodle 2.3 banner block which allows banners to be uploaded by users and displayed in an animated carousel.

Note that in Moodle 2 you can configure your theme to display block regions where you like – I’ve added a block region to the top of my middle column and placed a banner block there.
The video shows a second banner block [Star Pupils] of different image dimensions


(moodle 2.3 demo – test site)

Features:

  • Uploaded banners can be hyperlinked to a user specified URL
  • Banners can be uploaded from a given date for a given number of days
  • The banner block is styled to take up minimal vertical height – a title/title strip can be added if required.
  • For each banner block instance

    • The dimensions of the upload banner can be configured – non-conforming banners are rejected
    • The display time per banner can be configured
    • Users can pause and scroll manually through the banners
    • The max number of days for a banner to be displayed can be configured
    • The block can be configured to accept posts from everyone or just block editors

We find all our best designed banners are created by students πŸ™‚

Advertisements

36 responses to “Banners block for moodle 2.3

  1. nadavkav 10/11/2012 at 15:24

    Amazing! thanks for sharing πŸ™‚
    I will let you know how our teachers responded to this beautiful new feature

    Nadav πŸ™‚
    (Tiny little fix… please update the source link to : https://github.com/drcheckers/moodle-block_banners.git )

    • drcheckers 10/11/2012 at 16:23

      Fixed the link – thanks.

      Feedback always welcome πŸ™‚

      • nadavkav 10/11/2012 at 16:31

        I have installed it on a Moodle 2.4dev, and got :
        1) JS error: “Uncaught ReferenceError: YAHOO is not defined” on the first line of banner.js
        2) After submitting a new image I get an error while redirecting, saying “course id is missing”

        I guess it all relate to changes in APIs from Moodle 2.3 to 2.4dev.

      • drcheckers 10/11/2012 at 16:54

        Hmmm – I haven’t started on 2.4 yet. If you have any ideas for solutions to the above I can integrate – should work on 2.3 though.

      • drcheckers 11/11/2012 at 21:30

        Just uploaded some minor fixes
        I believe changing all refs to YAHOO into Y.YUI2 in banners.js makes it work in 2.4dev [according to my testing] – though I can’t recreate problem 2.

        Anyway enjoy – better get back to my day job πŸ™‚

      • nadavkav 12/11/2012 at 04:04

        “changing all refs to YAHOO into Y.YUI2 in banners.js makes it work in 2.4dev” πŸ™‚
        Thanks!

        Now, It only works when in LTR mode (English UI). Switching the RTL mode (ie. Hebrew) … the images are not visible. (No JS errors) probably something with the CSS and the position calculations from the left side of the window ( I will try to fix that )

      • drcheckers 12/11/2012 at 07:40

        Not sure about that one – all the calculations are done inside the YUI carousel widget … I don’t know much about RTL mode – presumed it only effected text. You mean the banners are not visible or the smaller control icons?

      • nadavkav 12/11/2012 at 15:42

        Only “the banners are not visible” in RTL mode. (I used firebug, to see they are off screen, or something.) I will go through the carousel calculation and see if I can fix it.

      • nadavkav 10/11/2012 at 16:34

        Also, since the blocks need first time configurations/setup…
        It would be helpful to users that you add a notice about it inside the block’s content area, if it was just added and not configured yet.

      • drcheckers 10/11/2012 at 16:52

        I’ll get it to self-initialise to some defaults – will post update tomorrow

      • drcheckers 11/11/2012 at 11:07

        Updated the initialisation issue – will take some time before I look at 2.4 [in process of downloading]

  2. Mary Cooch (@moodlefairy) 10/11/2012 at 18:46

    Hi there. This looks very interesting and useful! Just wondered if you are planning to (or have you already) shared it in the Moodle.org plugins database? https://moodle.org/plugins/index.php

  3. metzy 11/11/2012 at 11:42

    Great work and many thanks for sharing. We are upgrading soon and will test this out.

  4. Hugh 12/11/2012 at 15:00

    Looks good, looking forward to trying it out!

  5. Lisa 12/11/2012 at 22:59

    Nice work! Have been trying it out today on our Moodle 2.3.2 install and I keep getting a “Must specify course id, short name or idnumber” error message when I add banners. The banners are there and do work but it’s annoying having to keep reloading the course each time after it chucks me out πŸ™‚ Any ideas what I need to edit on our Moodle or is it something within the block?

  6. Lisa 19/11/2012 at 16:43

    Works great, thank you for all the help πŸ™‚

  7. Mary Cooch 26/11/2012 at 23:36

    Hi there. How do I change the size? I added a banner block and it said it was for 600×120. I tried to add a small jpg but it said it was the wrong size and I can’t see where to alter the size. thanks πŸ™‚

    • drcheckers 27/11/2012 at 06:48

      Thanks for the review – I’ll try and upload an updated version and some documentation.
      I think the ‘pain’ of being strict on dimension pays off in the display – but I could, I guess, introduce some leniency [would have to think how]

    • drcheckers 28/11/2012 at 07:58

      I’ve put an update on git that I think solves the default access issue.

  8. georgeprout 29/11/2012 at 01:09

    Hard coded references to “mdl_” in the code means that if you use any other db prefix then it bombs out quite badly and renders the whole site inaccessible… fortunately that’s what dev sites are for πŸ˜‰ v2.3
    Emergency workaround was to make a copy of the table (prefix)_block_banners as mdl_block_banners, at least the site comes back up then. Just in case anyone else gets caught out, otherwise it looks good, thanks πŸ™‚

    • georgeprout 29/11/2012 at 01:43

      Fix: lib.php has the hardcoded “mdl_” prefix, a patch is below (there may be more references, as I’ve only had a quick look but apply the same fix to any others)

      function handleBannerURL($fileid,$url){
      global $CFG, $DB;
      $sql = “INSERT INTO “.$CFG->prefix.”block_banners

      function getBannerURL($fileid){
      global $CFG, $DB;
      $banner_url_obj = $DB->get_fieldset_sql(“SELECT url FROM “.$CFG->prefix.”block_banners WHERE fileid = “.$fileid);

      • drcheckers 29/11/2012 at 07:03

        Whoops – thanks for letting me know – I’ve uploaded fix to GIT hosted version [will update moodle databse version later]

        [ you can just use {block_banners} in 2.3 ]

  9. georgeprout 29/11/2012 at 10:03

    I saw the {block_banners} syntax, that’s a pretty cool addition that I’d not seen before, having only coded for older versions.
    There’s another minor fix – there’s a warning issued when full developer messages are on. edit_form.php seems to need a ‘global $attributes’ (should be obvious which of the two functions needs it) as it’s otherwise spitting out a warning that $attributes is not defined. I haven’t delved into the code to see what it does, and it seems to work ok without, but a warning is a warning after all πŸ˜‰ Feel free to delete this post rather than publish it!

  10. Matthew 10/01/2013 at 07:44

    Interesting Site!, well written and a good read. Thanks for sharing ! Thumbs up from me!

  11. Marcin Stanowski 14/01/2013 at 06:46

    A thing I was waiting long time, but how to make it appear in the centre position on home page in moodle 2..4. I know there used to be a patch in 1.9 but now, how did you make it work in your video?

  12. Marcin Stanowski 30/01/2013 at 00:26

    I beg for forgiveness, I am simply dumb

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: