Jump to content

Recommended Posts

I have a website that I did for my uncle and now, the requirements are going beyond my html knowledge and into the realm of server scripting.

 

My issue is that I need to loop through all the images in a given folder and subfolders and preload them into the html so that the user can view them within a slide show.  There are currently 6 subfolders with over 20 pics in each and there are more pics to come and different folders to add.  I have a media page with the first picture within each category (subfolder) displayed as an eye catcher to the category.  once the user clicks on the image, the slide show will start in a popup.  The problem is that with js, I have to list out every image since it cannot look through a directory listing.  I would like to simply call a server side script that will create an array of the images and preload them so that when the slide show is ran, the appropriate images will show.

 

I am found numerous scripts for preloading images, written in php, but I am unsure how to implement them and keep a html extension for my pages.  As the site is written entirely in html and javascript, I would like to keep the html extentions if possible. 

 

As this is my first site, I am sure that server side scripting will become a bigger role, but baby steps are what I need right now.  In addition, if anyone has a good site for learning the server scripting world, I would greatly appreciate the reference.

If you name all your pages with a php extension, the parser will go through that script.  If it finds no PHP code, it will just return the file to the browser.  In retrospect, it will slow the site down slightly, as it will take time for the parser to look at the file.

 

I have a script that grabs all images from a directory, but it is made for something a little different.  If you post your javascript code, I could put it in there for you.

 

 

Adding this in your .htaccess would result in all *.html files being executed as php, but I'm not sure if there are any disadvantages:

AddHandler x-httpd-php5 .html
AddType application/x-httpd-php5 .html

 

Do you happen to know if godaddy is setup this way?  Is there a simple test I can do to find out?

Adding this in your .htaccess would result in all *.html files being executed as php, but I'm not sure if there are any disadvantages:

AddHandler x-httpd-php5 .html
AddType application/x-httpd-php5 .html

 

Do you happen to know if godaddy is setup this way?  Is there a simple test I can do to find out?

 

Sure, make sure that code is in your .htaccess file.

 

test.html

<?php 
echo 'If this doesn\'t have the word echo in front of it, PHP is parsed!';
?>

Edit: I MUST ESCAPE!!!

Save the above box to a file, and call it with your browser.

Yes godaddy supports that, as well as mod rewrite rules which you could use for your existing pages.  A common strategy for dynamic websites is to make dynamically generated pages "appear" to be static html files using mod_rewrite.  It looks in this case like just remapping .html to be parsed as php is simpler but for completeness sake, I thought I'd mention the alternative.  For example, it's not an infrequent occurence that people completely rewrite a site and restructure it, however, they have a lot of google links to what would be obsolete urls, which they don't want to lose.  So they put in mod rewrite rules for these links that redirect to the new url where the content has been moved to.

 

 

I've used them and I've never had a problem using a .htaccess file. What makes you think you can't access yours?

 

when I browse through the ftp or file manager option, I have no such file.  I tried looking through the various setting pages, and nothing referenced .htaccess.

So I added a file .htaccess to the root of the site with the aforementioned information and created a test.html with the information listed and no luck.  Come to find out, I am using a Windows server and not an Linux so an .htaccess file will not work.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.