ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 19th, 2003, 08:37 AM
keir keir is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 5 keir User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post Multilevel database driven folder structure in ASP

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.

Reply With Quote
  #2  
Old May 21st, 2003, 12:16 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
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.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #3  
Old May 21st, 2003, 02:13 AM
keir keir is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 5 keir User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old May 21st, 2003, 02:32 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
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.

Reply With Quote
  #5  
Old May 21st, 2003, 03:28 PM
keir keir is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 5 keir User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by stumpy
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.


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.

Reply With Quote
  #6  
Old May 21st, 2003, 07:50 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Multilevel database driven folder structure in ASP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway