Results 1 to 8 of 8

Thread: Dynamically randomly populated categorized images in sidebar

  1. #1
    Join Date
    Mar 2011
    Location
    The Netherlands
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Dynamically randomly populated categorized images in sidebar

    Hey guys,

    After a long search on several scripting websites I eventually found this forum. I've been trying to find a script that does the following:

    - Display random images on page refresh
    - Retrieve the random images automatically from a folder
    - The images have to be divided in categories

    For example, I want 6 images vertically aligned in my sidebar on my website. 6 different categories. And each time a user refreshes the page, all 6 images have to be replaced by another image from 1 of those 6 categorized folders.

    I've been looking in the Swiss Army script, written by jscheuer1, which works amazing, but the code is way too complex for my beginner skills. It basically does exactly what I want the script to do on my website, but I don't know if can be customized the way I want it, displaying 6 images from 6 locations and cycle when being refreshed. Can anyone give me some tips on how I can achieve this?

    ps. I'm sorry about the 'descriptive' title.
    Last edited by arjenjonge; 03-08-2011 at 03:00 PM. Reason: grammar, spelling, clarity

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    If you can use php on your server you could try this script here: http://www.marcofolio.net/webdesign/..._rotation.html

    Just upload a copy of the default "rotate.php" file from the download pack into each category image folder (folders 1 to 6) and then add this HTML to your web page;
    Code:
    <img src="path/to/folder1/rotate.php" height="150" width="150" alt=""/><br/>
    <img src="path/to/folder2/rotate.php" height="150" width="150" alt=""/><br/>
    <img src="path/to/folder3/rotate.php" height="150" width="150" alt=""/><br/>
    <img src="path/to/folder4/rotate.php" height="150" width="150" alt=""/><br/>
    <img src="path/to/folder5/rotate.php" height="150" width="150" alt=""/><br/>
    <img src="path/to/folder6/rotate.php" height="150" width="150" alt=""/>
    Make sure each src="" value points to the "rotate.php" files in the different category image folders.

    That should be it.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    arjenjonge (03-08-2011)

  4. #3
    Join Date
    Mar 2011
    Location
    The Netherlands
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Wow! Thanks for the quick and helpful reply! This is exactly what I needed!

  5. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    no problem - and welcome to DD!
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  6. #5
    Join Date
    Mar 2011
    Location
    The Netherlands
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    And I'm back. The PHP script doesn't seem to be working properly. I created the six folders, inserted the images and the rotate.php script in each folder, and inserted the HTML code on my main page, linking to the correct folders.

    The PHP scripts seems to be loading one of the images, but isn't rotating when refreshing the page. And when I changed the images, it kept displaying the (already deleted) old image for a while. Are the images cached when loading? This would explain why the image isn't refreshing instantly after deleting it on my server (and localhost, for testing purposes).

    I've tested the script in Chrome, Firefox 4 Beta, and Safari. They all give the same result.

    Link to my testing page: http://www.arjendejonge.nl/msv/sidebar/index.php

  7. #6
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Probably a cache issue - there is some talk of it in the comments on that webpage from my first reply.

    Try adding this line after the initial opening <?php tag in each "rotate.php" script;
    PHP Code:
    header("Cache-Control: no-cache, must-revalidate"); 
    The default script is working fine for me though: http://jemthingsandstuff.co.uk/testi..._test/page.php
    Last edited by Beverleyh; 03-09-2011 at 10:48 AM. Reason: test page added
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  8. #7
    Join Date
    Mar 2011
    Location
    The Netherlands
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Adding the Cache-Control didn't help on my server. Strangely enough, it kinda works on my localhost. It definitely randomises the images, but in the same order. All the images are the same in all six folders, and all six images are the same when refreshed. This won't be a problem in the final version of the script ofcourse, since I won't be using duplicate images.

  9. #8
    Join Date
    Mar 2011
    Location
    The Netherlands
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Okay, bad news. PHP isnt supported on the webpage I'm supposed to edit. They wasted my time hahah. Ah well, another learning experience.


    Thanks for the help, and at least I know where I need to be when I need a script or help etc.

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
  •