Hi Nathan,

I've been thinking about this sporadically over the past couple of
weeks and I'm keen to see if you've made any progress. I have a couple
of questions about your proposed solution, which (aside from my
previous points) I quite like the look of.

First of all this line:

$mptt = new MPTT( array( 'table' => 'mytree' ) );

I've assumed (maybe incorrectly) that an instance of the MPTT class
basically represents a record in the vocabularies table. If I'm right
with that assumption:
- will it extend QueryRecord?
- what is the data being passed to the constructor?

Also, I've assumed that MPTTNode essentially represents a record in
the terms table.

In relation to this line:
$return = $mptt->get_node(27)->parent()->child(0)->append($mptt-
>create_node( array( 'slug' => 'javascript' ) ));

This seems to indicate that append(MPTTNode) is a method of the
MPTTNode class, which doesn't quite add up. Given that (almost) every
append action will necessarily involve manipulation of more than one
node in the tree, shouldn't the append method be part of the MPTT
class?

None of this is by way of criticism, just looking to clarify your
thoughts. I'm looking forward to seeing your implementation of this.
BTW, did anyone make a decision re: the parent field?

Cheers,
Simon


On Oct 17, 6:06 am, Nathan Hammond <[EMAIL PROTECTED]> wrote:
> Regardless of the eventual underlying implementation in terms of
> adjacency or MPTT, here is the syntax I'm coming up with:
>
> $mptt = new MPTT( array( 'table' => 'mytree' ) );
> $return = $mptt->get_node(27)->parent()->child(0)->append($mptt-
>
> >create_node( array( 'slug' => 'javascript' ) ));
>
> The way to describe that:
> 1. From the MPTT object defined by the table mytree;
> 2. Get node id 27;
> 3. Get node 27's parent;
> 4. Get the first child of node 27's parent;
> 5. Append the node that is created by the same MPTT object to the
> first child of node 27's parent.
> 6. Assign the return value of the last operation (the most recently
> touched node, in this case the new one) to $return.
>
> Of course, that is *way* overkill and anybody who is fiddling with
> their MPTT tree in that manner might need to get their head looked at.
> However, I'd rather enable that degree of complexity to be easily
> accomplished so that nobody has any need to modify this base class. By
> creating such an easy to use API I think we'd manage to avoid the
> problem of somebody wanting to directly fiddle with the tables.
> Hopefully.
>
> In any case, I'm basing this syntactical design off of JavaScript, and
> jQuery in particular, as that is my primary expertise. To accomplish
> this I am writing two classes: MPTT, representing the entire tree; and
> MPTTNode, representing just a specific node from that tree. Tree level
> operations (in general, operations performed on more than one node)
> are methods of the MPTT class. Node manipulation is handled by methods
> in the MPTTNode class. There may eventually be a third class as well,
> MPTTSet, which could be used to handle applying actions to all nodes
> currently selected (basically an enumerator), we'll see.
>
> Any comments on this approach?
> Nathan
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/habari-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to