|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hoping someone can help.
This bit I can do! Currently I am able to replicate a folder structure using an Access mdb and ASP. Basically I refer the page to itself and see if the requested folder ID has any child nodes and display its contents, whether they be other folders or content items. This method allows me to navigate my way up and down the structure and have an endless supply of nested folders, just like in Windows. This bit I can’t do! However it gets a little trickier when you want to display this structure graphically on one page as you need to loop through all the relationships without forgetting where you are in the tree and to be honest this has got me stumped! What I can’t get my head around is how to loop through the records whilst remembering where we have reached in the tree so when no more relationships have been found I can go back to the previous position. I am sure it can be done with arrays but have hit a brick wall trying to think it through. My basic database structure is as follows: tblFolders • ID (Auto number) • folderName • folderDesc • parentID (Default 0 to denote top level) If anyone has written any ASP code around this or has any ideas about the way forward I would be very grateful. Ideally I would like to be able to use this in an intranet project I am working on for two things, multi threaded discussions and a folder structure for documents. Thanks for any help. |
|
#2
|
||||
|
||||
|
You need to write a function that calls itself, called a recursive function. Works kinda like this:
function foo() 'do stuff if this folder has children, then call foo() end function Also, is there a reason you are storing the folder structure in a DB? Seems like you doubling up on a lot if info, and can easily make life very difficult. Use the Scripting.FileSystemObject included with ASP, which does all that file system related stuff for you. |
|
#3
|
|||
|
|||
|
Thanks for your reply Stumpy.
I have been playing around with recursive functions thanks to my further delving into Google. They are an amazing thing but it has taken me a while to understand how they work. I would have thought you needed to track where the function was so it knew how to get back when there are no more children (does that make sense?)! However it seems to be one of those black box programming things. The server just seems to know where it got to and when it can delve no further move back to where it came from. Apparently this is something to do with "the stack". In regard to your question about the DB I thoroughly agree with you about the FSO. If it was purely for docuemnts this would be the method of choice. However I wanted to try and get my head around the idea using a database as I want to try and implement a multi threaded discussion board on an intranet project I am currently working on and display all the threads (plus children) grpahically. This would involve showing varous DB records. |
|
#4
|
||||
|
||||
|
Ahh - well you could have picked something a bit easier than heirarchical DB structures to start off with! hehe.
I've recently built a threaded forum myself, and managed to do it without "recursivness".. i.e. I had a "topic" table, which held the first post of a thread, and a "replies" table which held replies. Although this isn't a truely "threaded" forum, it's what i'm used to these days, as most major forums around use this method over the rather confusing, multi-level threaded model from a few years ago. Re; the recursive calls - unless you need to, you don't need to know where you are so you can go back up the tree. You just build the children, and when you hit the end, move onto the next parent. Remember each call to the function creates a whole new area of memory for each var used, which is how it "keeps track" of where you are. And yeah - they're definately a tricky thing to get your head around. |
|
#5
|
|||
|
|||
|
Quote:
I agree, not the easiest thing to start off with but now I have it cracked I can apply it to various little projects I have lined up which is good. I agree about the forum layout as you describe, it is far easier to follow in that form. Have you tried the Snitz forums. I have used that on a few sites and it seems to offer a lot of useful functionality and it is free, uses ASP and a variety of databases. Thanks for all your help. |
|
#6
|
||||
|
||||
|
Yeah, about 6 hours into getting my forum to look good, aspnewbie told me about snitz.... It does have a ton of features but isn't easily customised graphically. I might use it for clients that aren't as deisgn focused, and want a v. powerful forum.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Multilevel database driven folder structure in ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|