Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: PHP directory parsing to html  (Read 4699 times)

Jason Kingery

  • Sr. Member
  • ****
  • Karma: 1
  • Posts: 298
    • http://denial-design.com
PHP directory parsing to html
« on: September 25, 2006, 02:09:30 pm »

OK, so I started working on a theme upload/viewer system. I have gotten as far as the uploader and unzipping the file with the correct directory structure.

Now I'm having problems figuring out how to parse the directory listing in php, and then grabbing only the sub directories, and being able to place them into an html dropdown form.

Any ideas? Or point to a good tutorial?

David

  • Hero Member
  • *****
  • Karma: 7
  • Posts: 567
PHP directory parsing to html
« Reply #1 on: September 25, 2006, 02:25:47 pm »

i'm very interested too ;)
Logged

Jason Kingery

  • Sr. Member
  • ****
  • Karma: 1
  • Posts: 298
    • http://denial-design.com
PHP directory parsing to html
« Reply #2 on: September 25, 2006, 02:45:28 pm »

heh, I'm hoping to have a fully automated system ready for beta in the next week or so. I just figured for the beta, I would use your already tried and true system, just automate it, and add automated download link. Then when all is working, I will add the ajax goodness. I just think it will be a lot nicer to be able to hide the "frame" or "shelf" as it's called in ajax when looking at the design.

Still no luck on the whole parsing thing, I'm still trying a few more ideas before I call it a night. :)

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
PHP directory parsing to html
« Reply #3 on: September 25, 2006, 08:37:57 pm »

try http://au3.php.net/manual/en/function.is-dir.php#49570
It may be more than you need, but it is the first example I found.

or something like this .. untested
Code: [Select]
$handle = opendir(".");
while($file = readdir($handle)) {
if(is_dir($file)) echo "$file/\n";
}
closedir($handle);
you would then just loop thru' the resulting array, and output to dropdown code.
Logged
Of all the things I have lost, it is my mind that I miss the most.

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1717
    • http://www.snewscms.com
PHP directory parsing to html
« Reply #4 on: September 25, 2006, 08:50:49 pm »

Quote from: DENiAL
Now I'm having problems figuring out how to parse the directory listing in php, and then grabbing only the sub directories, and being able to place them into an html dropdown form.

Any ideas? Or point to a good tutorial?
You could examine files function inside sNews 1.5.
Logged

Jason Kingery

  • Sr. Member
  • ****
  • Karma: 1
  • Posts: 298
    • http://denial-design.com
PHP directory parsing to html
« Reply #5 on: September 26, 2006, 12:29:33 pm »

Quote from: philmoz
try http://au3.php.net/manual/en/function.is-dir.php#49570
It may be more than you need, but it is the first example I found.

or something like this .. untested
Code: [Select]
$handle = opendir(".");
while($file = readdir($handle)) {
if(is_dir($file)) echo "$file/\n";
}
closedir($handle);
you would then just loop thru' the resulting array, and output to dropdown code.
I have gotten to that point. But I'm not sure how to loop to html, I have never been very good at working with the two languages as one.

Here is the html:
Code: [Select]
<form name="selectform">
<select name="template" onchange="loadTemplate();">
    <!--  Here the values are the directory name of the templates...  -->
<option value="ploneclone" selected="selected">Plone Clone</option>
<option value="twopointoh">Two Point Oh</option>
<option value="ebizniz">E Biz Niz</option>
<option value="merchant">Merchant</option>
<option value="myth">Myth</option>
<option value="darksim">Dark Sim</option>
<option value="dark solucija">Dark Solucija</option>
<option value="day1">Day 1</option>
<option value="day2">Day 2</option>
<option value="day3">Day 3</option>
<option value="dub1">Dub 1</option>
<option value="noname">No Name</option>
<option value="tidy">Tidy</option>
<option value="desizzle">Desizlle</option>
<option value="nixxed">Nixxed</option>
</select>
</form>
Now I can get 1 direcory to work, but I'm having problems with looping it, and outputting seperate code for each option. So if I have more then one directory, then at this point it would output as:

Code: [Select]
<option value="directory1,directory2,directory3">Two Point Oh</option>instead of:
Code: [Select]
<option value="directory1">Two Point Oh</option>
<option value="directory2">Two Point Oh</option>
<option value="directory3">Two Point Oh</option>
« Last Edit: December 17, 2008, 07:03:56 am by Joost »
Logged