Jump to content
xisto Community

jibberweed

Members
  • Content Count

    2
  • Joined

  • Last visited

  1. I got it im giving complete code to allow even expandable file structure hope this helps someone besides my self. as note i changed quite a bit. if you want the java files just ask and i will send them to you <?php/* Rendering */ function list_dir($path) { $items = get_sorted_entries($path); if (!$items) return; foreach($items as $item) { if ($item->type=='dir') { echo ("<li><img alt='PDF' src='../../../images/Folder.png'>".$item->entry."\n"); echo "<ul>\n";list_dir($item->full_path); } else { echo "<img alt='PDF' src='../../../images/PDF.png'> ".$item->entry."<br/>";} } echo "</ul>"; echo "</li>\n";} /* Finding */ function get_sorted_entries($path) { $dir_handle = @opendir($path) ; $items = array(); while (false !== ($item = readdir($dir_handle))) { $dir =$path.'/'.$item; if ( $item == '.' || $item =='..' ) continue; if(is_dir($dir)) { $items[] = (object) array('type'=>'dir','entry'=>$item, 'full_path'=>$dir); } else { $items[] = (object) array('type'=>'file','entry'=>$item, 'full_path'=>$dir); } } closedir($dir_handle); usort($items,'_sort_entries'); return $items; } /* Sorting */ function _sort_entries($a, $ { return strcmp($a->entry,$b->entry); }?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/ xmlns="http://forums.xisto.com/no_longer_exists/; <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> <title>TITLE</title> <link rel="stylesheet" href="../jquery.treeview.css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script> <script src="../lib/jquery.cookie.js" type="text/javascript"></script> <script src="../jquery.treeview.js" type="text/javascript"></script> <script type="text/javascript" src="demo.js"></script> </head> <body> <div id="treecontrol"> <a title="Collapse the entire tree below" href="#"> Collapse All</a> | <a title="Expand the entire tree below" href="#"> Expand All</a> | <a title="Toggle the tree below, opening closed branches, closing open branches" href="#"> Toggle All</a> </div><ul id="red" class="treeview-red"><?php list_dir("directory you want to search"); ?> </ul><hr /> </body></html> Untitled-1.pdf
  2. Wondering if any one can help me out. I can use the following script to display the files and folders but only the files are in alphabetical and not the folders, I know it will be using another array but cant seem to get it to work. If you want a link to the sample page just ask me to send an email, Im sure the forum rules were i cant post a link to my site, but if im told its ok i will. Im posting here because i used a little script from this Post to help with ording the files. I attached a screen shot to show what im doing . Thanks <?phpfunction ListFolder($path){$narray=array(); //using the opendir function $dir_handle = @opendir($path) or die("Unable to open $path"); //Leave only the lastest folder name $dirname = end(explode("/", $path));$i=0; //display the target folder. echo ("<li><img alt='PDF' src='../images/Folder.png'> $dirname\n"); echo "<ul>\n"; while (false !== ($file = readdir($dir_handle))) { if($file!="." && $file!="..") { if (is_dir($path."/".$file)) { //Display a list of sub folders. ListFolder($path."/".$file); } else { //Display a list of files.// echo "<img alt='PDF' src='../images/PDF.png'> $file<br/>"; $narray[$i]=$file; $i++; } } } //closing the directory closedir($dir_handle);sort($narray); for($i=0; $i<sizeof($narray); $i++) { echo "<img alt='PDF' src='../images/PDF.png'> $narray[$i]<br/>";} echo "</ul>\n"; echo "</li>\n";}?> Untitled-1.pdf
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.