Dreamweaver CS4 - How to display a website directory/folder as an webpage
dreamweaver cs4 - how "display website directory/folder webpage"?
you need server side script that. following complete example using php. copy new dw document , view.
<!doctype html> <html> <head> <meta charset="utf-8"> <title>directory contents</title> <style> * { padding: 0; margin: 0; } body { color: #333; font: 14px sans-serif; padding: 50px; background: #eee; } h1 { text-align: center; padding: 20px 0 12px 0; margin: 0; } h2 { font-size: 16px; text-align: center; padding: 0 0 12px 0; } #container { box-shadow: 0 5px 10px -5px rgba(0, 0, 0, 0.5); position: relative; background: white; } table { background-color: #f3f3f3; border-collapse: collapse; width: 100%; margin: 15px 0; } th { background-color: #fe4902; color: #fff; cursor: pointer; padding: 5px 10px; } th small { font-size: 9px; } td, th { text-align: left; } { text-decoration: none; } td { color: #663300; display: block; padding: 5px 10px; } th { padding-left: 0 } td:first-of-type { background: url(./.images/file.png) no-repeat 10px 50%; padding-left: 35px; } th:first-of-type { padding-left: 35px; } td:not(:first-of-type) { background-image: none !important; } tr:nth-of-type(odd) { background-color: #e6e6e6; } tr:hover td { background-color: #cacaca; } tr:hover td { color: #000; } /* icons file types (icons famfamfam) */ /* images */ table tr td:first-of-type a[href$=".jpg"], table tr td:first-of-type a[href$=".png"], table tr td:first-of-type a[href$=".gif"], table tr td:first-of-type a[href$=".svg"], table tr td:first-of-type a[href$=".jpeg"] { background-image: url(./.images/image.png); } /* zips */ table tr td:first-of-type a[href$=".zip"] { background-image: url(./.images/zip.png); } /* css */ table tr td:first-of-type a[href$=".css"] { background-image: url(./.images/css.png); } /* docs */ table tr td:first-of-type a[href$=".doc"], table tr td:first-of-type a[href$=".docx"], table tr td:first-of-type a[href$=".ppt"], table tr td:first-of-type a[href$=".pptx"], table tr td:first-of-type a[href$=".pps"], table tr td:first-of-type a[href$=".ppsx"], table tr td:first-of-type a[href$=".xls"], table tr td:first-of-type a[href$=".xlsx"] { background-image: url(./.images/office.png) } /* videos */ table tr td:first-of-type a[href$=".avi"], table tr td:first-of-type a[href$=".wmv"], table tr td:first-of-type a[href$=".mp4"], table tr td:first-of-type a[href$=".mov"], table tr td:first-of-type a[href$=".m4a"] { background-image: url(./.images/video.png); } /* audio */ table tr td:first-of-type a[href$=".mp3"], table tr td:first-of-type a[href$=".ogg"], table tr td:first-of-type a[href$=".aac"], table tr td:first-of-type a[href$=".wma"] { background-image: url(./.images/audio.png); } /* web pages */ table tr td:first-of-type a[href$=".html"], table tr td:first-of-type a[href$=".htm"], table tr td:first-of-type a[href$=".xml"] { background-image: url(./.images/xml.png); } table tr td:first-of-type a[href$=".php"] { background-image: url(./.images/php.png); } table tr td:first-of-type a[href$=".js"] { background-image: url(./.images/script.png); } /* directories */ table tr.dir td:first-of-type { background-image: url(./.images/folder.png); } </style> </head> <body> <div id="container"> <h1>directory contents</h1> <table class="sortable"> <thead> <tr> <th>filename</th> <th>type</th> <th>size <small>(bytes)</small></th> <th>date modified</th> </tr> </thead> <tbody> <?php // opens directory $mydirectory=opendir("."); // gets each entry while($entryname=readdir($mydirectory)) { $dirarray[]=$entryname; } // finds extensions of files function findexts ($filename) { $filename=strtolower($filename); $exts = explode("[/\\.]", $filename); $n=count($exts)-1; $exts=$exts[$n]; return $exts; } // closes directory closedir($mydirectory); // counts elements in array $indexcount=count($dirarray); // sorts files sort($dirarray); // loops through array of files for($index=0; $index < $indexcount; $index++) { // allows ./?hidden show hidden files if($_server['query_string']=="hidden") {$hide=""; $ahref="./"; $atext="hide";} else {$hide="."; $ahref="./?hidden"; $atext="show";} if(substr("$dirarray[$index]", 0, 1) != $hide) { // gets file names $name=$dirarray[$index]; $namehref=$dirarray[$index]; // gets extensions $extn=findexts($dirarray[$index]); // gets file size $size=number_format(filesize($dirarray[$index])); // gets date modified data $modtime=date("m j y g:i a", filemtime($dirarray[$index])); $timekey=date("ymdhis", filemtime($dirarray[$index])); // prettifies file types, add more suit needs. switch ($extn){ case "png": $extn="png image"; break; case "jpg": $extn="jpeg image"; break; case "svg": $extn="svg image"; break; case "gif": $extn="gif image"; break; case "ico": $extn="windows icon"; break; case "txt": $extn="text file"; break; case "log": $extn="log file"; break; case "htm": $extn="html file"; break; case "php": $extn="php script"; break; case "js": $extn="javascript"; break; case "css": $extn="stylesheet"; break; case "pdf": $extn="pdf document"; break; case "zip": $extn="zip archive"; break; case "bak": $extn="backup file"; break; default: $extn=strtoupper($extn)." file"; break; } // separates directories if(is_dir($dirarray[$index])) { $extn="<directory>"; $size="<directory>"; $class="dir"; } else { $class="file"; } // cleans . , .. directories if($name=="."){$name=". (current directory)"; $extn="<system dir>";} if($name==".."){$name=".. (parent directory)"; $extn="<system dir>";} // print 'em print(" <tr class='$class'> <td><a href='./$namehref'>$name</a></td> <td><a href='./$namehref'>$extn</a></td> <td><a href='./$namehref'>$size</a></td> <td sorttable_customkey='$timekey'><a href='./$namehref'>$modtime</a></td> </tr>"); } } ?> </tbody> </table> <h2><?php print("<a href='$ahref'>$atext hidden files</a>"); ?></h2> </div> </body> </html>
More discussions in Dreamweaver support forum
adobe
Comments
Post a Comment