Wednesday, June 2, 2010

Re: tricky list re-ordering problem

On Jun 2, 12:18 am, Jeremy Burns <jeremybu...@me.com> wrote:
> You mention tree behaviour but I don't see any parent, left or right fields.

I haven't implemented this (yet) with Tree. I mentioned it because
this is how I've done it in the past. But, in this case I can't see
how to use it because, normally, everything in the DB table would be a
single tree. In this case, I've got to have several separate lists
(trees), one for each DocumentSection.

> Just want to clarify a few things...are these accurate statements?
>
> - A section has many documents

yes

> - The order is (i) section then (ii) documents within the section

yes

> - The document order is not based on the name of the document

The client wishes to be able to re-order the documents within a given
section.

> If so, wouldn't a 'sort_order' column in the documents table fix this? If so, the order becomes (i) section.name (ii) document.sort_order.

Perhaps, but I can't see how that could be implemented, nor how I'd
change the order. Here's a concrete example:

section_1
document_a
document_b
document_c
document_d

section_2
document_e
document_f
document_g

The client wishes to change them to look like:

section_1
document_a
document_c
document_d
document_b

section_2
document_g
document_e
document_f

I can't figure out how I would do this using Tree Behavior, as I've
done in the past. A sort_order column might do the trick but I'm
having some trouble wrapping my head around that. How would I handle a
new Document being added to section_1, for example? My inclination
would be for it to be added to the end of the section, and then, if
the client wished to do so, it could be re-ordered once its been
uploaded. But, if using a sort_order column, how to set that correctly
in the first place?

One idea I've been ruminating on is to dispense with a
document_sections table and, instead, have a root Document (that is
"virtual, and never shown) and then several more "virtual" Documents
representing the section names. IOW, the only real documents are those
on the 3rd level of the tree (and there are only ever 3 levels).

I'm going to give that a shot and see how it goes.

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: