Closed Thread Icon

Topic awaiting preservation: please please help me - urgent! (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=12755" title="Pages that link to Topic awaiting preservation: please please help me - urgent! (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: please please help me - urgent! <span class="small">(Page 1 of 1)</span>\

 
smonkey
Paranoid (IV) Inmate

From: Northumberland, England
Insane since: Apr 2003

posted posted 05-21-2003 19:35

I have posted similar things like this before but have as yet to achieve my goal. Time is short and I still haven't figured out enough php to get this working. Basically I want to create a menu tree like:
http://www.gazingus.org/html/menuExpandable3.html

by using a php script to move through my sites folder structure and dynamically create the html page required to make the tree menu (the gazingus method uses a nested lists method)

I now have a php that will store my site files as absolute paths in an array. the trouble is I can't figure out how to get the array into a format to make the menu tree.

My aim is to have my php script run periodically using a cron job thing, and for this php script to create the html page that is the menu tree. I don't know how to do this so I'm hoping someone out there can spend 30 minutes expanding the script to include this functionaility.

my file listing script is:<BLOCKQUOTE><FONT face="Verdana, Arial">code:</font><HR><pre><?php

/* Extraction of files information from a certain directory.
* The function declared, parseDir will go through all files and
* sub-directories of the directory used to first call it. This function
* is recursive, which means it calls itself if a sub-directory is
* encountered. It's execution ends when there is no more file and/or
* directories in the directory used to first call it.*/

$root_path = ".";
function parseDir($path)
{
if (!($dir_handler = opendir($path))) {
die("Can't opendir() path '". $path ."'");
}
$files = array();
while (($file = readdir($dir_handler)) !== false) {
$temp_path = realpath($path."/".$file);
if ($file != "." && $file != "..") {
if (is_dir($temp_path)) {
$files = array_merge($files, parseDir($temp_path));
} elseif (is_file($temp_path)) {
$pathInfo = pathinfo($temp_path);
if (preg_match("/(html?

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 05-22-2003 00:44

smonkey: I'm afraid I don't have the time to do this for you but here is my script which does almost exactly what you want:
http://development.gurusnetwork.com/work/emperor/node_nav.txt

It is dirty and messy and not for circulation (although I hope to work it up into a tutorial one day and clean things up) but it should work.

Basically if you can get your information into an array of the forum:

$child_parent[$count]['node_id'] = $row['node_id'];
$child_parent[$count]['node_name'] = $row['node_name'];
$child_parent[$count]['parent_id'] = $row['parent_id'];

Then it should work. It is too much processing to be done every time (and may be slightly more complex than you might require) but if you are using cron it should be OK.

___________________
Emps

FAQs: Emperor

smonkey
Paranoid (IV) Inmate

From: Northumberland, England
Insane since: Apr 2003

posted posted 05-22-2003 01:28

Ok thanks emps, I'm at a loss as to what it actually does and what it doesn't do, I'm not very bright when it comes to code, markup is more my thing. When I try to run it as a standalone php file it generates a fatal error on line 9 - this line refers to a function that doesn't seem to exist (so it tells me) - 'Call to undefined function: db_quicksearch()' . Also when I look at it there is mention of sql albeit a variable '$sql', do I need sql to run this?

I appreciate your help emps, but if anyone (or emps) can help explain how the code works, how I should implement it, and what actually happens then that would be great. It's not that your (emps) code is hard to understand, it's just that I'm stupid. I'd like someone to show me how to do it and tell me why it works.

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 05-22-2003 01:44

smonkey - it isn't going to run out of the box for you. The first bit:

code:
//includes

$sql = "SELECT node_parent_link.node_id, node_parent_link.parent_id, node_main.node_name
FROM node_parent_link, node_main
WHERE node_parent_link.node_id = node_main.node_id";

$result = db_quicksearch ($sql);

/* we load the data into an array */

$count = 0;

while ($row = mysql_fetch_array($result)) {

$child_parent[$count]['node_id'] = $row['node_id'];
$child_parent[$count]['node_name'] = $row['node_name'];
$child_parent[$count]['parent_id'] = $row['parent_id'];

$count++;

}



brings in variables and functions and queries a database and loads the data into an array. As you are getting your data from elsewhere (that parseDir() function) that bit is largely irrelevant for your purposes.

I can't guarantee that this will be much help for you but if you can load the array in the manner above (I'd imagine you would just need parent and child paths then you may be able to cobble this together.

I'm afraid that I can't do it for you and these things do take time.........

___________________
Emps

FAQs: Emperor

smonkey
Paranoid (IV) Inmate

From: Northumberland, England
Insane since: Apr 2003

posted posted 05-22-2003 02:57

Thanks emps, what you said hasn't helped me much, not that that is your fault - it is mine coz I'm dumb. If you haven't got time then I can understand that, but I will hold out hope that someone does have some free time to do some cobbling, either using your script or the two bits I mentioned in my original post.

Anybody out there have some free time? maybe you had a funeral to go to and it turned out the person wasn't actually dead and now you are at a loss as to what to spend your day doing? maybe you had a weekend of sordid motel sex planned with the sexy babe you met the other day but realised she had a penis and was really a truck driver called Harry. Whatever your story I need you.

rickindy
Nervous Wreck (II) Inmate

From: Indianapolis, In USA
Insane since: Jan 2002

posted posted 05-22-2003 14:16

You need what's called a recursive directory search. Poked around at phpbuilder anf found two or three listed here
http://www.phpbuilder.net/snippet/browse.php?by=cat&cat=8

HTH


Few problems in life can't be solved by chocolate

smonkey
Paranoid (IV) Inmate

From: Northumberland, England
Insane since: Apr 2003

posted posted 05-22-2003 16:12

Rickindy: I think I already have the recursive directoy thing that you speak of (see example code in first post) - I have been through all the ones listed in your link but none seem to do anything a great deal different. Let me know if I'm worng here.

My goal is to use a recursive directory/file listing script to create a expandable menu tree like: http://www.gazingus.org/html/menuExpandable3.html

What I need is somebody with a little free time to expand the script I have (or one of there own) to be able to create a separate html page that contains the data to create a file menu tree like in the link above (gazingus uses nested lists to create the file tree, this method is nice to old browsers and search engines)

rickindy
Nervous Wreck (II) Inmate

From: Indianapolis, In USA
Insane since: Jan 2002

posted posted 05-22-2003 21:06

If you look at the source for gazingus' page, you should be able to see that the page consists of not only the assorted elements of the site, but also uses an external javascript menu tool. It looks an extandable tree menu, which you can find examples of by searching for them on google.

I would get one of the examples you find and then understand how it works and then see how to apply it to your site.

It's going to be a project, but I guess you're already aware of that.



Few problems in life can't be solved by chocolate

smonkey
Paranoid (IV) Inmate

From: Northumberland, England
Insane since: Apr 2003

posted posted 05-22-2003 21:49

Rickindy: I have the source for gazingus' file tree - I know it uses external javascript - this isn't my question.

What I wanted was a way to get the data created from my recursive file listing script into the html format required by the gazingus file tree (or any other file tree)

I can't do that myself coz I don't know how, I was hoping someone here could spend a little time making it work for me. A long shot I know, but I'm out of options.

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 05-22-2003 23:34

I hate to say this, but asking one of us to write custom code for you is totally unreasonable. Emperor provided you with code that does what you need and just needs a little tweaking. We don't know how your server is set up, so we have no way of writing code that is guaranteed to work on your system.

We like to help people because we believe a sharing community benefits everyone. But we aren't here to do your work for you, we are here to facilitate your understanding. If you don't want to learn how to do this stuff, then you need to either pay someone else to do it or you need to find an approach that is more your style. I'm sorry if that sounds harsh, but your message sounds more like a work order than a question. Please refer to http://www.catb.org/~esr/faqs/smart-questions.html .

For the record, your other question is much better.


-jiblet

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 05-23-2003 00:17

no doubt...

start with baby steps. First in plain words tell us what is wrong with this script, why won't it work for what you are trying to do? (This is for your sake not ours).

Now what needs to change in order for it to work? (As specific as possible)

How can you do this? <--- once you get here you'll find us much more helpful



.:[ Never resist a perfect moment ]:.

smonkey
Paranoid (IV) Inmate

From: Northumberland, England
Insane since: Apr 2003

posted posted 05-23-2003 02:41

I get the point of what you guys are here for, and I know that it isn't because you enjoy doing work for people for free.

Not being a coder of any description means I tend to misunderstand a lot of what you guys say and find hints and tips you give me to usually be unhelpful (through no fault of your own). My problem lies with the fact that I know nothing about code, and to that problem your solution would be for me to go away and learn, start with the basics and build up - trouble is, in certain situations there isn't enough time to learn the required steps in order to complete a project.

This script I want is not for a commercial project I'm working on, neither is it for a college project that I need to do in order to pass a course - it is for a community arts website I run at my own expense for anyone who wishes to use it.

I appreciate that you guys are busy too, and I understand perfectly when no one can help because of it. I didn't think the script I wanted would be that hard to create for you knowledgeable guys - to me, an unknowledgeable design student, it seems perfectly reasonable that to format the output of a script (that already reads all directories as required into and array), into the required html code (that is basically nested lists) needed by the javascript would be a pretty quick and simple task - I can't imagine it being more than 5 - 10 lines maximum.

But if you guys say that it is harder than this then I believe you. I don't believe that the final script created would be of use to me only tho, I think it has a place on the web as a very useful resource for everyone - I mean it is a script that creates an explorer type interface for everything on your website and requires no input of data from the user - what better navigation could there be? I also don't believe that the script would have to be custom made for me and of no use to anbody else - the file listing script already works for anybody on any website with php, there is nothing custom about it, and by putting the information from it into an explorer type interface is not custom either - it would work for any site where the creator used directories efficiently and logically. My directory structure is irrelevant in this post because of this - it is not only about me and my site.

My final comment is about people posting just to have a go at me for asking for assistance - if you are that pissed at me or that busy that you don't want to help then why even waste the time posting a negative remark when you could stay silent and let this thread slide out of the forum. In my first post I acknowledged the fact that I was asking a lot - "I know you guys hate doing stuff like this" so why should anyone therefore feel the need to post a comment saying that they didn't like doing stuff like this? I already knew that!

Thanks again emps for posting constructive comments, thanks rickindy for trying to help allthough I get the impression that my post was a little confusing, thanks bitty for once again reminding to start simple and build up - one day I will follow your advice and probably be better for it. No thanks to jiblet, your comment was pointless and argumentative, you'd do better to spend your time helping people with questions you consider valid.

Bye guys, and if this thread has offended you with it's lack of community spirit and worthiness then get a moderator to delete the fucking thing.

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 05-23-2003 21:13

Please note firstly that I answered your other question in full.

Now, though you may not see it, there was a reason I posted here. It was TO EDUCATE, same as an answer to a question. I'm sorry you take offense, but please go back and read your questions and responses in this thread. You repeatedly say that you are just dumb, don't understand coding, need explanation of how the script works etc. First of all, we don't know what part it is you don't understand and why, so where do we begin explaining? Secondly, you don't give any evidence that you've spent any time at all trying to solve this problem, so why should we?

If you're a design student, you'll need to learn to take criticism. All I'm saying is that you should ask specific questions with specific backgrounds, like your .htaccess problem. When you really get suck on something is the time to post a question. Being experienced coders doesn't give us a magical ability to whip up whole blocks of code from scratch to convert an array of filenames into a full-blown Javascript. You do the work and we'll help you when you get stuck.

This isn't a personal attack on you, it's advice on how to get your questions answered. That's what you want isn't it?

-jiblet

« BackwardsOnwards »

Show Forum Drop Down Menu