• Script to diplay included HTML pages

    Home » Forums » Developers, developers, developers » Web design and development » Script to diplay included HTML pages

    Author
    Topic
    #440417

    I am looking for a script that works like ‘include’ only instead of just including 1 HTML file, it will include all the HTML files in a designated directory. If I can do this, it avoids updating 3 different HTML pages with the ‘include’ coding and I can just have the user upload the html file to the ‘include’ directory instead of editing the HTML page.

    Viewing 1 reply thread
    Author
    Replies
    • #1055203

      When you say script, do you mean a server-side script like ASP? ASP pages use VBScript, so you can pretty easily write code to retrieve all the files in a folder. On the other hand, if you mean a client-side script, then it’s quite unlikely that you could retrieve all the file names in a folder on the server… there’s no readily accessible public interface for that (and certainly you wouldn’t include any privileged passwords in a client-side script).

    • #1055898

      You could always have a single file with all the include files in, then include that file in the pages. e.g.

      include/include_root.php :

      ----------

      index.php:

      ...

      ...

      ---------

      This may save some time in the long run, as per a script for directory inclusion… Perhaps you can create a php script that uses a method that scans the dir, and includes each file,

      include/include_root.php:

      1){ //Removes the . and .. that is returned from readdir
      $file_array[$count - 2] = $file; //Appends the files found to an array
      }
      $count++;
      }
      closedir($dir);
      foreach($file_array as $inc_file){ //Cycle through the file array, include each file
      include ("include/".$inc_file); //Ensure root dir is same as your opendir()
      }
      }else{
      echo "Error.";
      }
      ?>

      index.php remains the same

      Feel free to use without my header, i attached a fully functional example, with all neccessary items. Be careful what you put in your include directory.

      This also assume you have php support.

    Viewing 1 reply thread
    Reply To: Script to diplay included HTML pages

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: