Creating multiple files?

Discussion in 'HTML & Website Design' started by Looie131, Aug 6, 2006.

  1. #1
    Alright everyone, is there any way of easily creating several HTML files without having to keep renaming and saving? I have a number of .jpg pictures and would like a HTML page for each individual picture with that same name. That might be pushing it but never hurts to ask.

    Up to this point I've just been renaming similar pages and changing the image, but that gets tiring so I am looking for something a bit faster. Any help is appreciated!:)
     
    Looie131, Aug 6, 2006 IP
  2. Danny

    Danny Active Member

    Messages:
    732
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    78
    #2
    you could write a quick php or asp script that would do it automatically for you

    What is in the HTMl page just the image

    Once you have a list of all the images (say a directory) you could just iterate through them and create them on the fly
     
    Danny, Aug 6, 2006 IP
  3. Looie131

    Looie131 Well-Known Member

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    116
    #3
    Unfortunately i don't know any php:( . I guess i'll have to learn really quick.

    I'm using Dreamweaver and i have a template and the pictures would go in the center in an editable region.

    Time to go learn some new stuff! Thank you for your help:)
     
    Looie131, Aug 6, 2006 IP
  4. Danny

    Danny Active Member

    Messages:
    732
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    78
    #4
    there are possibly programs out there that will do this but I had to do something fairly similar a few weeks ago and used ASP as it was the only language on the server. It took 10 minutes to write the script and saved me about 2 days work :)
     
    Danny, Aug 6, 2006 IP
  5. Looie131

    Looie131 Well-Known Member

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    116
    #5
    So i've been poking around in the world of php. But maybe some one can help me cause i couldn't seem to find an answer.
    I have this template in dreamweaver, is it possible to make that work with php. or do i have to redo it all with php script?

    And then about the number of pages i already have complete using this HTML template. Grrr, it seems im just getting more confused as i type this question. How would i go about taking that content and making it usable with php?
     
    Looie131, Aug 6, 2006 IP
  6. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #6
    It's not difficult. If you want, I can help you with both PHP (web based), and a desktop based application for this task.
    Send me a PM if you are interested. :)
    Bye
     
    JEET, Aug 6, 2006 IP
  7. Danny

    Danny Active Member

    Messages:
    732
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    78
    #7
    basically you need to access the file system.

    So you need to look at the directory with all the images, then use a foreach loop to look at each image and create a file (using your template) with the image name.html

    Pretyy eash script I just dont jbae much time at the moment or I would write it for you,
     
    Danny, Aug 6, 2006 IP
  8. Looie131

    Looie131 Well-Known Member

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    116
    #8
    From what i have seen from poking around it does seem easy, but i just don't understand the script at the moment, so a little more research wouldn't hurt. Plus JEET is going to help me out abit!
     
    Looie131, Aug 7, 2006 IP
  9. Edynas

    Edynas Peon

    Messages:
    796
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Before you start making a file for every image take a look at .htaccess
    It is not hard to make just 1 page that servers every image you want.

    First you need the index. You can place it in any php file you want and this is just a sample
    <?
    
    //define the path as relative
    $path = "/home/httpd/vhosts/spoono.com/httpdocs";
    
    //using the opendir function
    $dir_handle = @opendir($path) or die("Unable to open $path");
    
    echo "All images of $path<br/>";
    
    //running the while loop
    while ($file = readdir($dir_handle)) 
    {
       if($file!="." && $file!="..")
    //replace the jpg gif and jpeg part
    $file2 = eregi_replace(".jpg", "", $file);
    $file2 = eregi_replace(".jpeg", "", $file);
    $file2 = eregi_replace(".gif", "", $file);
    
          echo "&lt;a href='./pages/$file2.php'&gt;$file&lt;/a&gt;&lt;br/&gt;";
    }
    
    //closing the directory
    closedir($dir_handle);
    
    ?> 
    
    
    PHP:
    next the .htaccess part

    
    RewriteEngine on
    RewriteRule ^pages/(.*).php product.php?keyword=$1
    
    Code (markup):
    The page product.php will serve as a dynamic page. When ever an image page is called it will go to the directory pages. If you have an image called mynewimage.jpg it will link to the page www.yourwebsite.com/pages/mynewimage.php

    the htaccess will take care of the page as mynewimage.php does not excist but it will be calling product.php?keyword=mynewimage
     
    Edynas, Aug 8, 2006 IP
  10. Looie131

    Looie131 Well-Known Member

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    116
    #10
    Ok... so how would i go about implementing these codes?
     
    Looie131, Aug 9, 2006 IP