I'm trying to make ddblock to show different starting slide each time someone come to our website, but still display the slideshow in the same display order every time. The slideshow should also run the slides by the display order.
The random sort order seems to do it, however even though it starts with a different slide each time someone visit our website, it actually change the display order of the slide show randomly.
At the moment what seems to work for me is to put this code in the custom option:
{"random":1}
This gives me a different starting slide, while have the same display order for the slideshow. However, when the slide transits to the next slide, it actually jump randomly from slide to slide. (eg. Slide2 --> slide6 --> Slide 1 … ) . What should I do now to make the slideshow run the slides by the display order (eg. Slide 5 --> Slide 6 --> Slide 7 … )
Hope Someone can help out.
Comments
Comment #1
ppblaauw commentedTo implement functionality you require, there would be two possible options:
This could be done in a cookie on the computer of the user.
When the user visits again you read the start slide from last time (from the cookie) and start the slideshow with the next slide (slide + 1).
If (slide + 1) is bigger than the amount of slides, you would need to start the slideshow with slide 1
Hope this helps you further, please let me know.
Comment #2
johnshih commentedHi ppblaauw,
OPTION1:
I'm not quite sure how to set up the cookie for drupal.
I never wrote my own cookie before.
This is my attempt. Am I close?
Also, where should I place the cookie? should I put it in the "page.tpl.php" (theme folder)?
OPTION 2:
How to I start with a random start slide?
Comment #3
johnshih commentedHi ppblaauw,
I didn't really know how change the start slideshow using those 2 options you have suggested.
However, I hard code in jquery.cycle.all.min and got it to work.
And here is the code that I've changed.
/******variable numRand will be a random number between 0 and 7********/
var adjustedHigh = (parseFloat(7) - parseFloat(0)) + 1;var numRand = Math.floor(Math.random()*adjustedHigh) + parseFloat(0);
/****************************************************************/
$.fn.cycle.defaults={fx:"fade",timeout:4000,timeoutFn:null,continuous:0,speed:1000,speedIn:null,speedOut:null,next:null,prev:null,prevNextClick:null,pager:null,pagerClick:null,pagerEvent:"click",pagerAnchorBuilder:null,before:null,after:null,end:null,easing:null,easeIn:null,easeOut:null,shuffle:null,animIn:null,animOut:null,cssBefore:null,cssAfter:null,fxFn:null,height:"auto",
/*************startingSlide:0 --> numRand *******************/
startingSlide:numRand,
/********************************************************/
sync:1,random:0,fit:0,containerResize:1,pause:0,pauseOnPagerHover:0,autostop:0,autostopCount:0,delay:0,slideExpr:null,cleartype:!$.support.opacity,nowrap:0,fastOnEvent:0,randomizeEffects:1,rev:0};})(jQuery);
Comment #4
ppblaauw commentedthanks for the inspiration
Will implement the following in the dev version of ddblock.
First part is to start a slide from the URL.
The second part is to be able to start also random from the custom jquery field.
will create a patch later
the code can be placed before the line: // simple block
in the ddblock.js file of the module
Comment #5
johnshih commentedHi ppblaauw,
This did not work for me. I'm not sure why.
I've deleted my code and added in your new code in ddblock.js
Then I've put {"startingSlide":"random"} in the custom jquery field.
However nothing happen. It always start the slide with the first slide.
Comment #6
ppblaauw commentedYou would need to use the dev version of the ddblock module, the rc6 version does not set the nrOfItems.
Comment #7
johnshih commentedI upgrade my module to 6..x-1.x-dev version and put the new code in. Everything works fine.
However, ddblock stopped working after I put {"startingSlide":"random"} in the custom jquery field.
Comment #8
ppblaauw commentedDo you have a link to your site?
Do you see a javascript error?
Comment #9
johnshih commentedHi ppblaauw,
start with slidenr from URL is working.I do have 1 javascript error after I put {"startingSlide":"random"} in the custom jquery field:
**************************************************************
FIREFOX ERROR
**************************************************************
uncaught exception: [Exception... "Could not convert JavaScript argument arg 0 [nsIDOMViewCSS.getComputedStyle]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://localhost/sites/all/modules/jquery_update/replace/jquery.min.js?w :: anonymous :: line 22" data: no]
**************************************************************
IE ERROR
**************************************************************
Message: Unterminated string constant
Line: 774
Char: 38
Code: 0
URI: http://localhost/
Message: 'style' is null or not an object
Line: 10
Char: 3164
Code: 0
URI: http://localhost/sites/all/modules/ddblock/js/jquery.cycle.all.min.js?w
Comment #10
ppblaauw commentedDo you have a WYSIWYG editor for the custom jQuery field which adds other tags or code?
Do you have a link to your site?
Comment #11
johnshih commentedHi ppblaauw,
No additional tags or code was in the custom jquery field.
When I put this it works : {"startingSlide":2}
but this doesn't work : {"startingSlide":"random"}
Edit: Sorry, start with slider from URL does not work.
http://localhost/?slidenum=2 (This works)
http://localhost/?slidenum=random (This doesn't work)
Comment #12
johnshih commentedHi ppblaauw,
I still couldn't figure out how to get your code working for me.
So I place below code (bold) back into jquery.cycle.all.min.js and it works fine.
...opts.animIn={opacity:1};opts.animOut={opacity:0};opts.cssBefore={top:0,left:0};}};
/*variable numRand will be a random number between 0 and 7*/
var randomSlide = Math.floor(Math.random() * 7);
$.fn.cycle.ver=function(){return ver;};$.fn.cycle.defaults={fx:"fade",timeout:4000,timeoutFn:null,continuous:0,speed:1000,speedIn:null,speedOut:null,next:null,prev:null,onPrevNextEvent:null,prevNextEvent:"click.cycle",pager:null,onPagerEvent:null,pagerEvent:"click.cycle",allowPagerClickBubble:false,pagerAnchorBuilder:null,before:null,after:null,end:null,easing:null,easeIn:null,easeOut:null,shuffle:null,animIn:null,animOut:null,cssBefore:null,cssAfter:null,fxFn:null,height:"auto",
startingSlide:randomSlide
sync:1,random:0,fit:0,containerResize:1,slideResize:1,pause:0,pauseOnPagerHover:0,autostop:0,autostopCount:0,delay:0,slideExpr:null,cleartype:!$.support.opacity,cleartypeNoBg:false,nowrap:0,fastOnEvent:0,randomizeEffects:1,rev:0,manualTrump:true,requeueOnImageNotLoaded:true,requeueTimeout:250,activePagerClass:"activeSlide",updateActivePagerLink:null,backwards:false};})(jQuery);
Comment #13
ppblaauw commentedSet status to fixed.
Working as designed on my testserver.