jquery slider show

jquery slider show

by Richard Harris -
Number of replies: 6

Hi,

I'm struggling to get a slider working on our front page.  The jquery slideshow block doesn't quite do what we want.  I've tried various sliders such as the nivo slider, coda slider and the wow slider (www.wowslider.com).  The first two proved to be too much for my very limited (non-existent) coding skills so the desktop software of wow slider looked promising, but again I fell down on the publishing bit.  They all say the code should go into the header section of the index.html and moodle doesn't seem to have this.  I've been putting the jquery and css files into the theme we use, but if I put the html bit into a label for example it doesn't seem to be able to find them and just spits out a static thing.

Can anyone help me with instructions for a dummy of a site administrator.

Many thanks,

Richard Harris.

Average of ratings: -
In reply to Richard Harris

Re: jquery slider show

by Alexander Dold -

Richard, did you ever get this figured out?  I'm trying to do something very similar with a jquery slider, but I've yet to have any luck with it.

Thanks,

Alex Dold

In reply to Alexander Dold

Re: jquery slider show

by David Kimball -

Does anyone know if 2.4 will allow the use of sliders in an easy to do way?

In reply to Richard Harris

Re: jquery slider show

by Fred Nipper -

Richard,

Are you trying to put a sliding graphic into the header on your Moodle site?  If so, I just implemented this into our site. I had to create a separate CSS file that had the details of the graphic and then had to write the code to make it change images in the header section of the general.php file of the theme (I am using base Serenity Theme, so another theme may have a slightly different structure).  Be aware though, that I still had to paste my folder with my images in several different locations throughout the site in order for them to show up on all screens.  I'm sure someone with a lot better coding experience than me could tell you how to fix that problem.

Also, just a tip that I've found helpful while working with graphics....I open up the site in Google Chrome and then use the inspect element feature as it will help you narrow down the code that you are looking at needing to change.

Hope this helps!

In reply to Fred Nipper

Re: jquery slider show

by David Kimball -

Fred, I would be grateful for the files you used as well as the url of the code in action.

David

In reply to David Kimball

Re: jquery slider show

by Fred Nipper -

David,

Unfortunately our Moodle is housed on an internal server, so anyone outside the organization won't be able to access and view.  However I am pasting the code that we used below.  Hopefully that will help and give you some ideas.  The first piece of code is for the separate file that we named imagerotate.css.  The second piece is what we had to put in the header section of our General.php file under the layout folder in the theme section.  Keep in mind that the image locations will need to be changed based on where you store them.  We have a separate folder that we keep ours in named images.

Separate file:

/*--Main Container--*/ .main_view {  float: left;  position: relative; } /*--Window/Masking Styles--*/ .window {  height:122px; width: 1701px;  overflow: hidden; /*--Hides anything outside of the set width/height--*/  position: relative;  border-bottom: none; } .image_reel {  position: absolute;  top: 0; left: 0;  z-index: 1 } .image_reel img {float: left;}

/*--Paging Styles--*/ .paging {  position: absolute;  bottom: 5px; right: -30px;  width: 178px; height:47px;  z-index: 100; /*--Assures the paging stays on the top layer--*/  text-align: center;  line-height: 40px;  background: url(paging_bg2.png) no-repeat;  display: none; /*--Hidden by default, will be later shown with jQuery--*/ } .paging a {  padding: 5px;  text-decoration: none;  color: white; } .paging a.active {  font-weight: bold;  background: gray;  border: 1px solid #610000;  -moz-border-radius: 3px;  -khtml-border-radius: 3px;  -webkit-border-radius: 3px; } .paging a:hover {font-weight: bold;}

 

To go into header section of General.php:

<?php

$hasheading = ($PAGE->heading); $hasnavbar = (empty($PAGE->layout_options['nonavbar']) && $PAGE->has_navbar()); $hasfooter = (empty($PAGE->layout_options['nofooter'])); $hassidepre = (empty($PAGE->layout_options['noblocks']) && $PAGE->blocks->region_has_content('side-pre', $OUTPUT)); $hassidepost = (empty($PAGE->layout_options['noblocks']) && $PAGE->blocks->region_has_content('side-post', $OUTPUT));

$showsidepre = ($hassidepre && !$PAGE->blocks->region_completely_docked('side-pre', $OUTPUT)); $showsidepost = ($hassidepost && !$PAGE->blocks->region_completely_docked('side-post', $OUTPUT)); $custommenu = $OUTPUT->custom_menu(); $hascustommenu = (empty($PAGE->layout_options['nocustommenu']) && !empty($custommenu));

$bodyclasses = array(); if ($showsidepre && !$showsidepost) {     $bodyclasses[] = 'side-pre-only'; } else if ($showsidepost && !$showsidepre) {     $bodyclasses[] = 'side-post-only'; } else if (!$showsidepost && !$showsidepre) {     $bodyclasses[] = 'content-only'; } if ($hascustommenu) {     $bodyclasses[] = 'has_custom_menu'; } echo $OUTPUT->doctype() ?> <html <?php echo $OUTPUT->htmlattributes() ?>> <head>     <title><?php echo $PAGE->title ?></title>     <link rel="shortcut icon" href="<?php echo $OUTPUT->pix_url('favicon', 'theme')?>" />     <?php echo $OUTPUT->standard_head_html() ?>     <script type="text/javascript" src="jquery-1.4.2.min.js"></script>     <link rel="stylesheet" type="text/css" href="ImageRotate.css"/> <script type="text/javascript">  $(document).ready(function() {   //Show the paging and activate its first link  $(".paging").show();  $(".paging a:first").addClass("active");  //Get size of the image, how many images there are, then determin the size of the image reel.  var imageWidth = $(".window").width();  var imageSum = $(".image_reel img").size();  var imageReelWidth = imageWidth * imageSum;    //Adjust the image reel to its new size  $(".image_reel").css({'width' : imageReelWidth});    //Paging  and Slider Function  rotate = function(){   var triggerID = $active.attr("rel") - 1; //Get number of times to slide   var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide     $(".paging a").removeClass('active'); //Remove all active class   $active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)     //Slider Animation   $(".image_reel").animate({    left: -image_reelPosition   }, 500 );  };    //Rotation  and Timing Event  rotateSwitch = function(){   play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds    $active = $('.paging a.active').next(); //Move to the next paging    if ( $active.length === 0) { //If paging reaches the end...     $active = $('.paging a:first'); //go back to first    }    rotate(); //Trigger the paging and slider function   }, 7000); //Timer speed in milliseconds (7 seconds)  };    rotateSwitch(); //Run function on launch    //On Hover  $(".image_reel a").hover(function() {   clearInterval(play); //Stop the rotation  }, function() {   rotateSwitch(); //Resume rotation timer  });     //On Click  $(".paging a").click(function() {   $active = $(this); //Activate the clicked paging   //Reset Timer   clearInterval(play); //Stop the rotation   rotate(); //Trigger rotation immediately   rotateSwitch(); // Resume rotation timer   return false; //Prevent browser jump to link anchor  });   }); </script> </head> <body id="<?php p($PAGE->bodyid) ?>" class="<?php p($PAGE->bodyclasses.' '.join(' ', $bodyclasses)) ?>"> <?php echo $OUTPUT->standard_top_of_body_html() ?>

<div id="page">  <div id="wrapper" class="clearfix"> <?php if ($hasheading || $hasnavbar) { ?>

    <div id="page-header" class="clearfix">

                         <?php if ($hasheading) { ?>        <!--<h1 class="headermain"><!--?php echo $PAGE->heading ?></h1> -->                           <!-- ROTATOR BEGIN -->       <div class="main_view">         <div class="window">           <div class="headermenu">  <?php                echo $OUTPUT->login_info();                if (!empty($PAGE->layout_options['langmenu'])) {                    echo $OUTPUT->lang_menu();             }                echo $PAGE->headingmenu            ?>           </div>                 <div class="image_reel"> <img src="images/reel/1.png" alt="" /></a> <img src="images/reel/2.png" alt="" /><img src="images/reel/3.png" alt="" /><img src="images/reel/4.png" alt="" /></a>           </div>         </div>         <div class="paging"> <a href="#" rel="1">1</a> <a href="#" rel="2">2</a> <a href="#" rel="3">3</a> <a href="#" rel="4">4</a>         </div> <!-- ROTATOR END -->                     <?php } ?>

    </div>

 <?php if ($hascustommenu) { ?>   <div id="custommenu"><?php echo $custommenu; ?></div>  <?php } ?>

    <?php if ($hasnavbar) { ?>      <div class="navbar clearfix">          <div class="breadcrumb"><?php echo $OUTPUT->navbar(); ?></div>             <div class="navbutton"> <?php echo $PAGE->button; ?></div>       </div>     <?php } ?>

<?php } ?>

 

Hope this helps!

 

Fred

 

In reply to Fred Nipper

Re: jquery slider show

by David Kimball -

Fred, was able to get the pictures in my header but right next to each other, not rotating.

Double checked the references to the jquery file.