Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Fade in slideshow using folder instead?

  1. #1
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Question Fade in slideshow using folder instead?

    http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm

    I have searched this forum for results but no luck.
    I am using ASP and would like to know how to use a folder instead?

    How to make this part only have the folder to list as many images as needed?
    PHP Code:
    var fadeimages=new Array()
    //SET IMAGE PATHS. Extend or contract array as needed
    fadeimages[0]=["photo1.jpg"""""
    fadeimages[1]=["photo2.jpg"""""
    If it's not possible in ASP then how to do it in javascript?

    Cheers
    Cool script by the way.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If your page's extension is .asp and the server is enabled for asp, you should be able to replace:

    Code:
    var fadeimages=new Array() 
    //SET IMAGE PATHS. Extend or contract array as needed 
    fadeimages[0]=["photo1.jpg", "", ""]  
    fadeimages[1]=["photo2.jpg", "", ""]
    with (which could also be used as an external file* - comments begin with '):

    Code:
    <%
    ' The Runtime code:
    ' Create some asp variables for
    Dim strPath   'Path of directory
    Dim objFSO    'FileSystemObject variable
    Dim objFolder 'Folder variable
    Dim objItem   'Variable used to loop through the contents of the folder
    
    ' You could just as easily read this from some sort of input
    ' NOTE: As currently implemented, this needs to end with the /
    strPath = "./"
    
    ' Create our FSO
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    
    ' Get a handle on our folder
    Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))
    
    'Create some javascript variables
    %>
    var counter=0
    var fadeimages=new Array()
    <%
    
    'Selecting only images
    Set RegExObj = New RegExp
    With RegExObj
    .Pattern = "gif|jpg|png"
    .IgnoreCase = True
    End With
    For Each objItem In objFolder.Files
    If RegExObj.Test(Right(objItem.Name, 3)) Then
    'Add each one to the array using javascript
    %>
    fadeimages[counter]=["<%= objItem.Name %>", "", ""]
    counter++
    <%
    End If
    Next 'objItem
    
    ' All done!  Kill off our asp object variables.
    Set objItem = Nothing
    Set objFolder = Nothing
    Set objFSO = Nothing
    Set RegExObj = Nothing
    %>
    It will grab all .jpg, .gif, and .png from the current folder. For a sub-folder, see the red highlighted part. Like for a folder off of the one that this page is in named images:

    strPath = "./images/"

    You would also need to add that path here:

    fadeimages[counter]=["images/<%= objItem.Name %>", "", ""]

    I've used similar code successfully. However, I don't know a great deal about asp, there could be a better way. The above is modeled loosely on and converted to asp from the 'getpics.php' used with this script:

    http://www.dynamicdrive.com/dynamici...photoalbum.htm

    *To use as an external file, you could just put it, without modifying the first path (the second one would still need to be modified), in the directory with the images, save it as getpics.asp. Then on your page with the slide show script, which could now be .htm or whatever, put this tag before the main slide show script on the page:

    Code:
    <script type="text/javascript" src="path/getpics.asp"></script>
    Where path/ is the absolute or relative path to the folder with the images and this getpics.asp file in it.

    And be sure to remove this:

    Code:
    var fadeimages=new Array() 
    //SET IMAGE PATHS. Extend or contract array as needed 
    fadeimages[0]=["photo1.jpg", "", ""]  
    fadeimages[1]=["photo2.jpg", "", ""]
    from the main slide show script.
    Last edited by jscheuer1; 02-13-2008 at 05:50 AM. Reason: Add more detail & correct one asp comment
    - John
    ________________________

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

  3. #3
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Default

    Unbelievable!!!
    I don't even know if it is right but this sh1t works!

    I was thinking exactly the same thing that you did,
    but wasn't sure where to place or what to do with the code.

    Thank you.

  4. #4
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Wink

    Just to add a bit warning to this thread of amazement.

    Do not remove this <body> tag if using it as an include on your page like so...

    Code:
    page data...
    <!--#include file="filename.asp" -->
    end page data...
    So the script would work like this...
    getpics.asp
    Code:
    <%the code%>
    random.asp
    Code:
    <script type="text/javascript" src="getpics.asp"></script>
    page data...
    <body> <!--do not remove this part, other html you can remove--> 
    rest of script
    end page data...
    Hope this makes sense.

    Cheers

  5. #5
    Join Date
    Apr 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hey John, do you by chance have a php version of this somewhere? I really need to have a fade script that pulls images in random order from a folder, but I just can't find one, and unfortunately don't have the php foo to write one.

    cheers,
    Jordan

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by formadmin View Post
    hey John, do you by chance have a php version of this somewhere? I really need to have a fade script that pulls images in random order from a folder, but I just can't find one, and unfortunately don't have the php foo to write one.

    cheers,
    Jordan
    There is a getpics.php file used with this script:

    http://www.dynamicdrive.com/dynamici...photoalbum.htm

    The code to which is here:

    http://www.dynamicdrive.com/dynamici...etpics.php.txt

    It would need to be modified slightly to output the desired array. The word galleryarray should be replaced by the word fadeimages in both places where it occurs. The entry in this line for filedate should be removed:

    PHP Code:
    echo 'galleryarray[' $curimage .']=["' $file '", "'.$filedate.'"];' "\n"
    so that it looks like so (also includes one instance of the other change I mentioned, make sure you get both):

    PHP Code:
    echo 'fadeimages[' $curimage .']=["' $file '", ""];' "\n"
    And some PHP servers also require one or both of two other tweaks. Let me know if you have problems.

    The two tweaks are:

    1 ) Opening the file with:

    PHP Code:
    <?php
    instead of just <? as it is now, and:

    2 ) Adding a slash (red) here:

    Code:
    function returnimages($dirname="./") {
    But these last two changes are rarely needed, at least as far as I know. And when they are needed, it's because the server is following a stricter syntax than PHP usually ships with.
    - John
    ________________________

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

  7. #7
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Thumbs up

    Quote Originally Posted by formadmin View Post
    hey John, do you by chance have a php version of this somewhere? I really need to have a fade script that pulls images in random order from a folder, but I just can't find one, and unfortunately don't have the php foo to write one.cheers, Jordan
    Go here, you'll find what you need: Link removed as requested.
    There is a PHP and ASP version for it.

    Cheers
    Last edited by ddadmin; 02-20-2009 at 04:01 AM.

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by student101 View Post
    Go here, you'll find what you need: Link removed as requested by OP
    There is a PHP and ASP version for it.

    Cheers
    That's very close to the same code. But it doesn't output the correctly formated array for this script. It may also have some problems when served as javascript, no mime type declaration. And its $dirname variable may also suffer (on stricter servers) from the same issue I mentioned in #2 of my previous post in this thread.
    Last edited by ddadmin; 02-20-2009 at 08:24 PM.
    - John
    ________________________

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

  9. #9
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Default

    I don't think I understand?
    It works, I can't complain.

    Cheers

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by student101 View Post
    I don't think I understand?
    Apparently not -

    I imagine it would work in many cases, the PHP or the asp code that is. It will make an array of images, one entry deep. Without modification though, it will not power the script properly, as the script requires a multidimensional array. However, the script will work, just not quite as intended*. And, as I said, on some servers the PHP code will not work or will not be served properly (see mention of this in my two previous posts).



    *The script expects a mutidimensional array, with each entry in the form of:

    Code:
    ['image_filename', 'link']
    if the second entry is missing entirely, instead of simply being blank or having a url in it, the image will link to the page itself (like an href="#" link). So either the script or the asp/PHP code could be modified to accommodate this fact. Or you could use the PHP code or the asp code already laid out in this thread, which already output the array in the expected format.
    - John
    ________________________

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

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
  •