TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-13-2009, 04:19 PM   #1 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Application Spaces to display levels in dir structure list ?

Good day to you all,

working on listing a directory the way I want, I'm trying that for each level of file there is a number of spaces in front of the file and/or folder of that level. EX :

Folder 1
--Folder 2
--Image 1
--Image 2
--Image 3
Image 1
Image 2

How can I add that spacing on each level ?

Here is my code :


PHP Code:


<?php

$directory 
"Art/";
function 
dirList ($directory)
{

    
//create 2 arrays - one for folders and one for files
   
$folders = array();
   
$files = array();

    
// create a handler for the directory
    
$handler opendir($directory);

    
// keep going until all files in directory have been read
while (false !== ($file readdir($handler))) {  

        
// if $file isn't this directory or its parent,
        // add it to the results array
        
if ($file != '.' && $file != '..')
        
        
// If file is directory, mark it in bold.
       
if(is_dir($directory.$file)) { 
        
array_push($folders,$file);
        
        
// Else not styled
        
}else{
        
array_push($files,$file);
        
    }
    }


    
// tidy up: close the handler
    
closedir($handler);

    foreach(
$folders as $folder) {
      echo 
"<strong>".$folder."</strong>  <a href=\"javascript:show('".$folder."');\">Show</a>- <a href=\"javascript:hide('".$folder."');\">Hide</a><br />";
        
echo 
"<div id=\"".$folder."\">";
dirList($directory.$folder.'/');

echo 
"<br/><br/></div>";
    
    
    }

    foreach(
$files as $file) {
      echo 
$file."<br />";
    }
    

}

dirList($directory);

?>
Thanks !
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Old 04-13-2009, 04:32 PM   #2 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

Make it so that it generates the HTML so it looks something like this:

Code:
<ul>
  <li>file</li>
  <li>dir<ul>
    <li>file</li>
    <li>file</li>
  </ul></li>
  <li>file</li>
  <li>file</li>
</ul>
It's really more of a HTML/CSS issue than a PHP one
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 04-13-2009, 05:40 PM   #3 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Separate your concerns.
  1. Fetch a hierarchical list of files/folders.
  2. Display that list however you want.

You seem to have many posts/threads asking pretty much the same thing, yet always revert back to the same basic code. Are you listening and taking note of replies to your threads?
Salathe is offline  
Reply With Quote
Old 04-13-2009, 05:53 PM   #4 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Default

I'm learning with many examples and trying to see the different way of coding.

I'm it could look as such, i'm soo a bit too.
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Databse structure Village Idiot TalkPHP Developer Team 3 01-16-2009 10:31 PM
Status List codefreek TalkPHP Developer Team 12 11-24-2008 12:23 AM
Need alphabetized directory list benton General 9 10-13-2008 06:34 PM
Menu Display Problem in IE6+ obolus XHTML, HTML, CSS 14 03-01-2008 07:57 PM


All times are GMT. The time now is 02:33 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design