Advanced Search

Results 1 to 3 of 3

Thread: Changing the initial slide displayed with the Simple Controls Gallery

  1. #1
    Join Date
    Aug 2013
    Posts
    11
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question Changing the initial slide displayed with the Simple Controls Gallery

    1) Script Title: Simple Controls Gallery

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...plegallery.htm

    3) Describe problem: When the gallery is displayed, the initial slide is set to the first. However, in my case, I have a need to *sometimes* start the gallery on the last slide, not always the first. Is there a way to launch the slideshow to have a variable to start it on first or last? I don't want to change the order of the slides, just begin the slideshow on the last slide

    I'm not all that familiar with Javascript, but the code has the following...here's the snipit...

    dfd.done(function(){ //execute when all images have loaded
    setting.$loadinggif.remove()
    setting.$wrapperdiv.bind('mouseenter', function(){slideshow.showhidenavpanel('show')})
    setting.$wrapperdiv.bind('mouseleave', function(){slideshow.showhidenavpanel('hide')})
    slideshow.showslide(setting.curimage) //show initial slide

    setting.oninit.call(slideshow) //trigger oninit() event

    So with slideshow.showslide(setting.curimage), I'd like to be able to display the last slide in the array as the initial. Can anyone suggest an easy way on how to do this? Thanks!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,704
    Thanks
    43
    Thanked 3,133 Times in 3,097 Posts
    Blog Entries
    12

    Default

    You don't need to edit the script. You can just set the curimage value right on the page. You have something like so to initialize the gallery on the page:

    Code:
    <script type="text/javascript">
    
    var mygallery=new simpleGallery({
    	wrapperid: "simplegallery1", //ID of main gallery container,
    	dimensions: [250, 180], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
    	imagearray: [
    		["pool.jpg", "http://en.wikipedia.org/wiki/Swimming_pool", "_new", ""],
    		["cave.jpg", "http://en.wikipedia.org/wiki/Cave", "", ""],
    		["fruits.jpg", "", "", ""],
    		["autumn.jpg", "", "", ""]
    	],
    	autoplay: [true, 2500, 2], //[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
    	persist: false,
    	fadeduration: 500, //transition duration (milliseconds)
    	oninit:function(){ //event that fires when gallery has initialized/ ready to run
    	},
    	onslide:function(curslide, i){ //event that fires after each slide is shown
    		//curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
    		//i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
    	}
    })
    
    mygallery.setting.curimage = mygallery.setting.imagearray.length - 1;
    
    </script>
    Just add the highlighted line at the end there as shown. Notice that the same variable name that was used to initialize the gallery (mygallery, shown in red) is used in two places to set the curimage value to that of the last slide's index in the gallery's imagearray.

    The browser cache may need to be cleared and/or the page refreshed to see changes.

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.

    That's it, couldn't be much simpler, unless you also want a way to determine whether or not to do that based upon the URL used to navigate to the page. For that you can use either server side code or more javascript. If you need that and want help with that, just let me know.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2013
    Posts
    11
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Thumbs up

    Quote Originally Posted by jscheuer1 View Post
    You don't need to edit the script. You can just set the curimage value right on the page. You have something like so to initialize the gallery on the page:

    Just add the highlighted line at the end there as shown. Notice that the same variable name that was used to initialize the gallery (mygallery, shown in red) is used in two places to set the curimage value to that of the last slide's index in the gallery's imagearray.

    The browser cache may need to be cleared and/or the page refreshed to see changes.

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.

    That's it, couldn't be much simpler, unless you also want a way to determine whether or not to do that based upon the URL used to navigate to the page. For that you can use either server side code or more javascript. If you need that and want help with that, just let me know.
    Wonderful John. That was the magic line. I also have an xml file that I read to determine whether or not to display the first or last slide initially. So, I took your line of code and wrapped in some php and BINGO...success!

    Code:
    <?php if($xml->TAB[$p_index]->LOOP=="Last"){?>
    mygallery.setting.curimage = mygallery.setting.imagearray.length - 1;
    <? } ?>

Similar Threads

  1. Simple Controls Gallery
    By emanuelle in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 02-02-2011, 10:38 AM
  2. Simple Controls Gallery v1.3 Problem with not Showing Images or Controls
    By macca85 in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 08-13-2009, 04:29 PM
  3. Simple Controls Gallery v1.3
    By adiem in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 06-28-2009, 05:37 PM
  4. Simple Controls Gallery simulating flash image changing
    By capnhud in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 06-03-2009, 10:04 AM
  5. Simple Controls Gallery - controls outside of images?
    By toolman in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 12-22-2008, 06:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •