Re: logic for displaying hierarchical data (ala windows explorer)
| From: | Sven | Date: | Tue, 16 Dec 2003 10:16:34 +0000 |
| Subject: | Re: logic for displaying hierarchical data (ala windows explorer) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-172785@lists.php.net to get a copy of this message | ||
Chris W. Parker schrieb:
Hi everyone, Last Friday I struggled for a long time with displaying some data that's stored using the Modified Preorder Tree Traversal method. Without making this email overly long and complicated (like my first draft was) I'd like to simply ask if someone has any links or functions or instructions they can give me on how to display my data in such a way. I want the following: Level 1A |--Level 2A | \--Level 3Ahi chris, just some thoughts: i assume you build your tree from leaves to root via recursive functions? if so you need a logic like this: <?php function isLastChild($self, $parent) {| |--Level 4A | | \--Level 5A | \--Level 3B|--Level 2B | \--Level 3C \--Level 2C \--Level 3D What I always end up with is this (or some variant of it): Level 1A |--Level 2A | \--Level 3A | | |--Level 4A | | | \--Level 5A | | \--Level 3B |--Level 2B | \--Level 3C \--Level 2C | \--Level 3D Any help is appreciated. Chris.
// check, whether $self is the last child of parent
// return true or false
}
if (!isLastChild($parent, $grandparent)) {
// draw your vertical line symbol} else {
// draw just a spaceholder} // following draw the label of $self ?> hope you understand, what i mean? hth SVEN