By: Keith Silva
Date: 2006-09-02
Time: 01:20
|
TBS and Treeview from DatabaseHas anyone used TBS to produce a treeview using data from a database? If so, perhaps you could provide an example. Did you use client-side Javascript to expand and collapse the nodes? Any examples, code or assistance you can provide would be appreciated.
Thanks, Keith Silva |
||||
By: Skrol29
Date: 2006-09-03
Time: 20:20
|
Re: TBS and Treeview from DatabaseHello,
Tree presentation is something that can be difficult to produce because Database system themselfs don't make it easy. You can find several threads on this forum about some ways of making it with TBS (use the search tool). But there is a project to offer a nicer solution with a TBS plug-in. I'm still working on it. |
||||
By: Keith Silva
Date: 2006-09-04
Time: 07:15
|
Re: TBS and Treeview from DatabaseThank you for the reply. Before I posted my message, I searched the forum using the keyword "treeview" which did not return any threads. In response to your reply I searched using the keyord "tree" and found a lot to read! Thanks for your help.
Regards, Keith Silva |
||||
By: Rudy
Date: 2011-04-06
Time: 17:19
|
Re: TBS and Treeview from DatabaseHi Skrol,
is there any update on this mysterious plugin? :) I'm REALLY interested in a finally easy way to merge tree menus without bloating code with brain-cracking lineage logic, using subqueries or faking a tree with indentation. I always have classic MySQL tree structures with id and parentid and fast enough views displaying it nicely with id, parentid, depth and caption - would be great to be able to merge it with one mergeblock-statement like tables. Thanks Rudy |
||||
By: Skrol29
Date: 2011-04-06
Time: 22:02
|
Re: TBS and Treeview from DatabaseWow.. you're digging up an old topic :)
The plug-in has been abandoned because the problem is solved by the tip & trics that you can found here: http://tinybutstrong.com/forum.php?thr=1833 |
||||
By: Rudy
Date: 2011-04-07
Time: 08:13
|
Re: TBS and Treeview from DatabaseHi Skrol,
yes I like digging in the past :) It's that I'm using that method you linked to all the time, but it's not what I'm after. With that method, I have to save the subblock in a global variable (which is the ugliest part), delete that block, merge the items with depth=0 and then use subqueries for the tree. Again, without lineage, is it possible to achieve same thing using a reusable ondata-function and one single mergeblock to generate a tree? Let's forget about the parentid, it really shouldn't matter because I'm trying to avoid subqueries - if I have a plain array with a field "depth" which goes from 0 (main items) to x (subitems) defining how deep the item is in the tree, how can I merge it creating a hierarchical structure?
Thanks for your help Rudy |
||||
By: Rudy
Date: 2011-04-08
Time: 09:32
|
Re: TBS and Treeview from DatabaseHere's how I solve it now - I decided to go the classic way for this task, of course there is no nice editable template but alle the markup is mixed in the php. On the other hand it's pretty short, easy to understand, requires no recursion and the items (from a mysql resultset) have to be walked through only once, exactly what I wish TBS could do. I would try to write a plugin on my own and share a working example, if someone could push me in the right direction, I just don't know where to start.
Thanks for any tips Rudy |
||||
By: kle_py
Date: 2011-04-08
Time: 18:00
|
Re: TBS and Treeview from Databasehere a solution i am using currently for a menu:
php like:
using a html template like:
maybe this example helps in some way... grat work skol - currently migrating to tbs3.7 ;) |
||||
By: Rudy
Date: 2011-04-10
Time: 01:21
|
Re: TBS and Treeview from DatabaseI was finally able to wrap it in a plugin which makes the merge process of trees easy. It's the first version and a little limited for the fact that the automatically added nesting containers (ol/ul) can't be changed (e.g. added attributes) during the merge process, but works for me to get quick results - I post it here maybe it's of some use.
The data structure in the example is an array, should be easy to reproduce a mysql query / view with the same data structure. Save and include as tbs_plugin_tree.php:
Example Use: Template: (nested.html)
The parameter "nested" has to be put in the block definition and is set to the tagname which should surround child elements (usually "ul" or "ol"). "level" tells the plugin which field in the resultset defines the depth of current element. PHP:
Here's the (tidied) result:
|
||||
By: Skrol29
Date: 2011-04-10
Time: 01:27
|
Re: TBS and Treeview from DatabaseMay I publish it ?
Is it possible to have a short manual ? |
||||
By: Rudy
Date: 2011-04-10
Time: 14:53
|
Re: TBS and Treeview from DatabaseThe previously posted plugin does not support database sources, it was the first try - you certainly shouldn't publish that :)
I now have a version that works with queries too, I'll mail it to you along with a mysql database example and manual in html format. |