Categories > TinyButStrong general >

Folder Tree

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: AllRound
Date: 2005-05-31
Time: 12:54

Folder Tree

In my database I have a table with document names and a table with folder names. Each folder can have a subfolder or a document as a "child".

What I want is to create a tree structure much like the windows file explorer tree structure. The problem is that I can't figure out a way to do this.

The result should be something like:

<sometag>Folder name</sometag>
    <sometag>Another Folder name</sometag>
        <sometag>Again Folder name</sometag>
        <othertag>Document name</othertag>
    <sometag>Folder name</sometag>
    <othertag>Other Document name</othertag>

Does anyone have a sollution for this problem?
By: RwD
Date: 2005-06-01
Time: 09:33

Re: Folder Tree

Well Bèr,
For one thing you might want to nest elements inside eachother to define parent-child relations. Secondly I think the <ul> and <li> elements are the ones you need.

I have asked a question about this exact same thing and as it turns out tbs is not good in dealing with nested tree structures but Skrol29 did however provide the solution. The thread this is in is called "Tree structure" currently on page 5 having a last replied date of "2005-02-25 09:45". Please do not reply in this thread, we'll keep your problem in your thread ;)

unfortunately I cannot link you to it as this forum is based on javascript.... (javascript:parent.m_Thr_Sel(window,562,2407))

I am not entirely certain if my solution is still exactly the same as I posted there. But the example there should be working anyway.
By: RwD
Date: 2005-06-01
Time: 09:45

Re: Folder Tree

Forgot to mention I use a nested set model for my tree structure and I only keep parent-child relations in the table so that I can benefit from both systems. I am certain you only use the parent-child model so in my example you also have to work out the correct query.

SELECT node_name, Level FROM MyTable ORDER BY Left
This is my query to extract all items in the tree structure and order them by the order they appear in the tree. I don't know of a way that is not recursive to do the same with a parent-child model. Perhaps you would also like to use the nested set model ;)

You can learn more about the nested set model here: http://www.sitepoint.com/article/hierarchical-data-database/2 and if you ask I'll give you my tree structure object.
By: Skrol29
Date: 2005-06-01
Time: 21:26

Re: Folder Tree

> unfortunately I cannot link you to it as this forum is based on javascript...

Arrrrrrrgggggggllllllllll ;)

There is a "Direct URL" copyable zone at the left of each post.
I discover with your message that this tip is unexplain and not friendly.

The direct URL for the message you mentionate is:
  http://www.tinybutstrong.com/forum.php?msg_id=2419

By: RwD
Date: 2005-06-02
Time: 10:10

Re: Folder Tree

Not to mention unreadable :P
Even when I read this it took me like a minute to find it :|

I had seen this Direct url text some times, but for some reason or the other I never connected it to being what it is. Instead I just read http:/ and thought it was because I didn't fill in the address to my website (even though that is not an option here, but it is at some other places)
Aah well, it is just the way the human mind works I guess ;)
By: AllRound
Date: 2005-06-02
Time: 15:39

Re: Folder Tree

In my PHP code I have an array with file/folder names, id's and the parent id of each. This array I want to convert to the html code I posted. Is this possible with mergeblock only?

The sollution of ruüdt is different, and I don't want to make it that way.
By: AllRound
Date: 2005-06-02
Time: 15:42

Re: Folder Tree

Can't there be a subblock of a subblock with mergeblock?
By: RwD
Date: 2005-06-03
Time: 09:23

Re: Folder Tree

The reason the solution I posted is the way that it is is because tbs cannot do a correct recursive tree in the way I asked (being ul is only allowed inside a li).

But Skrol29 also posted a different solution in that thread which leads to invalid html code but does display. I don't know your html coding standards, but if you want to continue cum-fraud that is perfectly ok ;)

The datasource is unimportant at any rate...
By: AllRound
Date: 2005-06-03
Time: 11:49

Re: Folder Tree

OK, but how would this solution work for my array?
By: AllRound
Date: 2005-06-03
Time: 12:49

Re: Folder Tree

Because the only thing I need is a simple tree structure (without worrying about the ul il whatever tags) from my array that has the file/folder names, id's and the parent id columns. That's my question, which is really different from Rwd's problem...
By: AllRound
Date: 2005-06-03
Time: 22:03

Re: Folder Tree

Is there maybe a way to use a subtemplate to achieve recursion to make a tree?