Any Solution to Order a generatetreelist output
Hi Mates, First off all, I would like to thank this group for being of great support. Guys, as in my project I was trying to display category list inside select box. I am using Tree List, so what I have in my table is: | id | category | parent_id | Currently I am using generatetreelist() that generates a good hierarchy of categories, but these are not in proper order. I mean, I wanted to order it according to category field. I tried many ways but didn't got the result, even later got confused while searching for a solution. May anyone please advice me a simple solution in this regards, would be thankful. Regards, Jayesh -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Any Solution to Order a generatetreelist output
if you are using Tree Behaviour the you need to use lft and rght field and it will create an array based on this values...:) -- Lep pozdrav, Tilen Majerle http://majerle.eu 2011/4/16 Mr.Jayesh jayeshach...@gmail.com Hi Mates, First off all, I would like to thank this group for being of great support. Guys, as in my project I was trying to display category list inside select box. I am using Tree List, so what I have in my table is: | id | category | parent_id | Currently I am using generatetreelist() that generates a good hierarchy of categories, but these are not in proper order. I mean, I wanted to order it according to category field. I tried many ways but didn't got the result, even later got confused while searching for a solution. May anyone please advice me a simple solution in this regards, would be thankful. Regards, Jayesh -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Any Solution to Order a generatetreelist output
Hi Jayesh, In the case of a Tree behaviour, the algorithm used to generate the tree is based on ordering, its not very trivial to use ordering on the regular sense on the tree, and maintain its structure at the same time. CakePHP's specific implemtation of this algorithm aside, one would implement this feature by factoring this in at record creation time, e.g. the complete tree's ordering is re-calculated whenever a new item is added, and at this time one could calculate the lft and rght value based on a tertiery factor, the category you mentioned. I'm not sure if such a feature is built into the CakePHP implementation of the MPTT algorithm. Its a pain to build it yourself. Google MPTT (Modified Pre-ordered Tree Traversal) in order for some more understanding of how the TreeBehavour and its ordering actually works. In short; Either you display the list as a tree, or you can display it ordered by another column and its tree structure will be lost. Regards, Yuka On Sat, Apr 16, 2011 at 11:08 PM, Tilen Majerle tilen.maje...@gmail.com wrote: if you are using Tree Behaviour the you need to use lft and rght field and it will create an array based on this values...:) -- Lep pozdrav, Tilen Majerle http://majerle.eu 2011/4/16 Mr.Jayesh jayeshach...@gmail.com Hi Mates, First off all, I would like to thank this group for being of great support. Guys, as in my project I was trying to display category list inside select box. I am using Tree List, so what I have in my table is: | id | category | parent_id | Currently I am using generatetreelist() that generates a good hierarchy of categories, but these are not in proper order. I mean, I wanted to order it according to category field. I tried many ways but didn't got the result, even later got confused while searching for a solution. May anyone please advice me a simple solution in this regards, would be thankful. Regards, Jayesh -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Any Solution to Order a generatetreelist output
like stated above, you need 'lft' and 'rght' fields in your table. check out this: http://en.wikipedia.org/wiki/Nested_set_model nested set model: wikipedia and you can figure out what to populate your fields with to start off. -- View this message in context: http://cakephp.1045679.n5.nabble.com/Any-Solution-to-Order-a-generatetreelist-output-tp4308116p4308453.html Sent from the CakePHP mailing list archive at Nabble.com. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php