Tuesday, June 29, 2010

Tree Behavior for Duplicate Entries?

The company I work for has a very loosly-organized system of
referencing pages which bears a modest resemblance to a Tree
structure. Their "menu" table contains pairs of "pageid" and
"levelid," with another element "line" to indicate the order in which
they appear. Any pageid could potentially be a levelid for another
group of elements and the same element might exist in several parts of
the "hierarchy."

For a variety of reasons, this system is not the most efficient
structure. For example, how does one go about determining a breadcrumb
trail or hierarchical list of these elements when there's no beginning
or end? It makes sense to me that switching to a tree structure would
be the preferred method to organize the data. But looking at the
documentation, it seems almost as though the Tree Behavior is not
setup to handle this type of data. Perhaps this is a shortcoming of
the documentation and not the Behavior:

// pseudo controller code
$data['Category']['parent_id'] = 3;
$data['Category']['name'] = 'Skating';
$this->Category->save($data);

Since in my case, the parent_id would be the levelid (which is
actually a SKU, if you can believe it), there are going to be more
than one location within the tree which will have that same levelid.
Can I also save by the ID of the given tree element instead? Is there
a problem with duplicating information in a Tree in this way?

I could play around with it, except that I don't have a lot of rights
to the database and can't really make many moves until I've got a bit
more information to act upon. I appreciate any help you guys can
provide me! Thanks

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: