Theme scheme scroller

Theme scheme scroller

by Gareth J Barnard -
Number of replies: 7
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi,

Does anybody know how it could be possible to implement a 'scheme scroller' for a theme in its 'settings.php' such that the user could move between preset colour schemes and then the code adapt and select the appropriate selectors?

E.g. in the attached image.

Cheers,

Gareth

Attachment Theme_Scroller.png
Average of ratings: -
In reply to Gareth J Barnard

Re: Theme scheme scroller

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Dear Gareth,

I know how to add a scroller in a layout page, but setting this in settings.php would definitely be a test of my php coding skills. smile

To tell you the truth I don't think there is a mechanism in place to allowing you to do this. We are struggling for someone to come up with getting the file-picker to work in the settings page, so people can upload a logo or header background image for their theme, to no avail.

So I am guessing this needs to be written into the HTML constructor, wherever that happens to be, for the Admin settings page which a theme's setting page is based on.

HTH

Mary

In reply to Mary Evans

Re: Theme scheme scroller

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Mary,

Do you have an example of the scroller on a layout page please?  As looking at http://docs.moodle.org/dev/Admin_settings - custom setting classes can be created.  Also, looking in '/lib/adminlib.php' there is a class 'admin_setting_configfile' which I think puts a file value into the 'config_plugins' table - might work.

Thanks,

Gareth

In reply to Gareth J Barnard

Re: Theme scheme scroller

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Yes, I used an earlier version of this http://bxslider.com/

This is better than the previous version as it is fully responsive and looks easier to implement.

In reply to Mary Evans

Re: Theme scheme scroller

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Thanks Mary,

The tricky bit will be doing the update back to the server to populate the value of the current slide.  I'll look at the colour picker admin setting as somehow it's javascript value gets to the server code.

Plus been thinking about the file picker issue, I think will be a hybrid of the file picker form and a text value stored in the database of the location of the local storage uploaded image using the editimage.php code from the Grid Format - not a trivial task.   Need to finish some other ideas first!

Thanks,

Gareth

In reply to Gareth J Barnard

Re: Theme scheme scroller

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Dear Gareth,

You can add JQuery to a theme's javascript directory and call it via the theme's config.php and it will be picked up by the theme's custom settings page, or should if that helps?

To get the BoxSlider to work in a layout file is as follows:

  1. ADD the HTML list of images as suggested (see below) inside a div container in the layout file where you want this to be.Usually in the frontpage.php just above <div id="page-content"> and after the end of the page header like so...
    <!-- End of Header -->
    <div id="bxslider-container">
    <ul class="bxslider">
      <li><img src="<?php echo $OUTPUT->pix_url('pic1', 'theme'); ?>" /></li>
      <li><img src="<?php echo $OUTPUT->pix_url('pic2', 'theme'); ?>" /></li>
      <li><img src="<?php echo $OUTPUT->pix_url('pic3', 'theme'); ?>" /></li>
      <li><img src="<?php echo $OUTPUT->pix_url('pic4', 'theme'); ?>" /></li>
    </ul>
    </div>
    <!-- Start of Main Content -->
    <div id="page-content">

  2. SAVE the 4 images to your theme's /pix directory
  3. ADD the bxslider CALL
    $(document).ready(function(){
      $('.bxslider').bxSlider();
    });
    to a single page file using your text editor, and save it as bxslider.js to your theme's /javascript/

  4. GRAB a copy of the jQuery files jquery.min.js & jquery.bxslider.min.js and ADD them to the same Javascript directory as the bxslider.js
  5. GRAB a copy of the jquery.bxslider.css and add that to your theme's style directory but rename it to bxslider.css as moodle does not recognise . in css filenames other than the .css file extension
  6. ADD the following lines into your theme's config.php
    $THEME->javascripts = array('bxslider')
    $THEME->javascripts_footer = array('jquery.min' , 'jquery.bxslider.min');

  7. ALSO add the 'bxslider', to the list of stylesheets in you theme config.php
  8. Better to check that the settings in the jquery.bxslider.js are correct and point to the location for all the files as described in 1 - 7 above, as they may be linked differently.

That's it....hopefully it should work. Remember to Purge all caches first befor trying it out.Then knowing how it works you may get to figure a way to get it to work via the setting's page.


Cheers

Mary

Average of ratings: Useful (2)
In reply to Mary Evans

Re: Theme scheme scroller

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Thank you Mary smile

What I intend to do is extend one of the text input admin settings, then pass in an array of associative array of labels => images, then detect the selected item and put in the text input box which is then passed back to the server on submit in the normal way.  This is a medium term implementation, so might be a while to see results, thank you for your help.

I fell asleep last night looking at the file picker issue, far more difficult as passing in a file to the server, looked at the Moodle Forms way and could not find the point where the JavaScript invoked the PHP to parse the file to the server.  The rest I think I can do.  Is there a MDL tracker for this as a boiler plate core addition would be useful for so many things?  Then it could be voted for and get team assistance in it's creation.

Cheers,

Gareth

 

In reply to Gareth J Barnard

Re: Theme scheme scroller

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Yes, Gareth,  there is a tracker set up for this already. MDL-35434 assigned to Rajesh, who is very helpful so I am sure he would be able to point you in the right direction if you asked him. I've added you as a watcher so you should get notification shortly, if you haven't already! smile

Mary