Hello,

Complete novice - but have searched the site and found the same issue here http://drupal.org/node/910050 - which is closed - what i would like to do now i have the slide show on all the pages .. is how to start with a random slide not always the same one.

I have read the solution here but i dont really know where this code goes and what the format is. If possible could someone tell me the exact code to put into the page.tpl.php file and where this would go in this file.

Thank you so much if you can help and i hope this is not repeated somewhere.

Thanks

A.

Comments

BarnieGirl’s picture

Assigned: BarnieGirl » Unassigned
Deepika.chavan’s picture

Hi,
1. Please add following line of code in template.php

drupal_add_js(drupal_get_path('theme', 'danland') . '/scripts/mycycle.js');

2. Create file mycycle.js in '/scripts' directory and add following js in it.

$(document).ready(function () {
$('.slideshow').cycle({ 
	random: 1,
});
});

I hope this is what you wanted. HTH !!

Rgrds,
Deepika Chavan.

BarnieGirl’s picture

Assigned: Unassigned » BarnieGirl

Hiya,

Thanks for this and your time it does seem like the right kind of thing.

I tryed it but it didnt seem to make any difference .

In the template.php .. I put your code drupal_add_js(drupal_get_path('theme', 'danland') . '/scripts/mycycle.js'); under where a similar code was drupal_add_js(drupal_get_path('theme', 'danland') . '/scripts/jquery.cycle.all.js'); and saved it.

Then i created the file mycycle.js as you said and put it in the folder /scripts

I then cleared all the caches, but it didnt appear to make any difference to the slide show at all. it always still starts with the same image and goes throught the same cycle.

Do you think i have missed something here - sorry to explain so much but i wanted to say exactly what i did in case it is wrong somehow.

Thank you.

p.s i also tryed removing the original line of code "drupal_add_js(drupal_get_path('theme', 'danland') . '/scripts/jquery.cycle.all.js');" but that just made a static image with no slide show.

Deepika.chavan’s picture

Hi,
I have no clue that where we are making mistake. Because I tried the above code on my local site, it shows different slide on different page instead of first slide and slideshow starts from that slide. This is what you wanted right?
Please do not remove drupal_add_js(drupal_get_path('theme', 'danland') . '/scripts/jquery.cycle.all.js'); line because it is a plugin and the slideshow and custom js is dependent on that js file.
Try following code, clear the cached data and see if the slides are shuffling or not.

$(document).ready(function () {
$('.slideshow').cycle({ 
	fx: 'shuffle',
	random: 1		
 });
});

While searching I got this http://www.cashmopolit.hr/howto/jquery/how_to_jquery_cycle.php Please see the examples.
Hth !!

Rgrds,

Deepika Chavan.

BarnieGirl’s picture

Hi,
Thank you i have tried the above again and with the different code - i still get the same image everytime i go to a new page even after clearing the cache I just wanted to check i put it all in the right place so i thought i would paste in what i have for each file. If you can help more thanks - I took two days off because it was melting my head :)

In File root/themes/danalnd/template.php i have the following code.

<?php
// $Id: template.php,v 1.10 2010/07/19 22:05:33 danprobo Exp $
function phptemplate_body_class($left, $right) {
if ($left && $right) {
$class = 'sidebars-2';
$id = 'sidebar-side-2';
}
else if ($left || $right) {
$class = 'sidebars-1';
$id = 'sidebar-side-1';
}

if(isset($class)) {
print ' class="'. $class .'"';
}
if(isset($id)) {
print ' id="'. $id .'"';
}
}

drupal_add_js(drupal_get_path('theme', 'danland') . '/scripts/jquery.cycle.all.js');

drupal_add_js(drupal_get_path('theme', 'danland') . '/scripts/mycycle.js');

In the file root/themes/danland/scripts/mycycle.js i have the following code.

$(document).ready(function () {
$('.slideshow').cycle({
fx: 'shuffle',
random: 1
});
});

I have also tried this with the first code sent - im still getting the same slideshow image on each new page and it goes in the same order - hmmm - confusing it looks like it should work.

Any help further very much appreciated

Thanks

A

danpros’s picture

Status: Active » Fixed

Hi,

Maybe the most simple is adding the config directly into page-front.tpl.php:

<script type="text/javascript">
jQuery(document).ready(function($) {
    $('.slideshow').cycle({
		fx: 'fade' , timeout: 8000, delay: 2000});
});</script>

Change it to this

<script type="text/javascript">
jQuery(document).ready(function($) {
    $('.slideshow').cycle({
		fx: 'fade' , random: 1, timeout: 8000, delay: 2000});
});</script>

Note: I adding the random: 1 value there.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.