Re: Slow reorder TreeBehaviour
On Oct 28, 10:09 am, Constantin.FF constantin...@gmail.com wrote: I need my tree sorted by each post sort value. Here is the function dealing with this. But it is executed extremely slow if some of the parents has more than 20-30 children function _sortPosts($newSort){ foreach ($newSort AS $id = $value) { if(is_numeric($value['sort'])){ $this-Post-updateAll(array('Post.sort' = $value['sort']), array('Post.id' = $id)); } else { $this-Session-setFlash(__('Non-numeric value given.', true), 'default', array('class' = 'error')); $this-redirect($this-referer()); } } foreach(array_keys($this-data['Post']) as $parent){ $this-Post-reorder(array('id' = $parent, 'field' = 'Post.sort', 'order' = 'ASC', 'verify' = true)); } why are you (still? Or do I just have deja vu) using another field to store the sort order - that's what lft is. if you _just_ call moveDown on each post in the order you want them to appear the tree will be in the order you expect. } Example: 38 posts, 8 parents and 30 children 5518 queries took 6028 ms Page rendered in 20032ms. Is there some other way to do this reorder without such a delay? The number of queries there most likely indicates an error in the tree behavior (145 queries per post) - if you look at what those queries are, you'll most likely be able to identify it and submit a pull request. AD -- 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: Slow reorder TreeBehaviour
Not a deja vu, just decided that will be much more comfortable to use a field with an order number and just once to click Save order than continuously clicking the moveDown or moveUp links until the desired position. Will check the queries On Fri, Oct 28, 2011 at 11:46 AM, AD7six andydawso...@gmail.com wrote: On Oct 28, 10:09 am, Constantin.FF constantin...@gmail.com wrote: I need my tree sorted by each post sort value. Here is the function dealing with this. But it is executed extremely slow if some of the parents has more than 20-30 children function _sortPosts($newSort){ foreach ($newSort AS $id = $value) { if(is_numeric($value['sort'])){ $this-Post-updateAll(array('Post.sort' = $value['sort']), array('Post.id' = $id)); } else { $this-Session-setFlash(__('Non-numeric value given.', true), 'default', array('class' = 'error')); $this-redirect($this-referer()); } } foreach(array_keys($this-data['Post']) as $parent){ $this-Post-reorder(array('id' = $parent, 'field' = 'Post.sort', 'order' = 'ASC', 'verify' = true)); } why are you (still? Or do I just have deja vu) using another field to store the sort order - that's what lft is. if you _just_ call moveDown on each post in the order you want them to appear the tree will be in the order you expect. } Example: 38 posts, 8 parents and 30 children 5518 queries took 6028 ms Page rendered in 20032ms. Is there some other way to do this reorder without such a delay? The number of queries there most likely indicates an error in the tree behavior (145 queries per post) - if you look at what those queries are, you'll most likely be able to identify it and submit a pull request. AD -- 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: Slow reorder TreeBehaviour
On Oct 28, 10:58 am, Constantin FF constantin...@gmail.com wrote: Not a deja vu, just decided that will be much more comfortable to use a field with an order number and just once to click Save order than continuously clicking the moveDown or moveUp links until the desired position. Who suggested doing that? -- 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: Slow reorder TreeBehaviour
Is there a better way for doing that? There is something similar in other CSM like joomla On Fri, Oct 28, 2011 at 12:11 PM, AD7six andydawso...@gmail.com wrote: On Oct 28, 10:58 am, Constantin FF constantin...@gmail.com wrote: Not a deja vu, just decided that will be much more comfortable to use a field with an order number and just once to click Save order than continuously clicking the moveDown or moveUp links until the desired position. Who suggested doing that? -- 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: Slow reorder TreeBehaviour
On Oct 28, 11:16 am, Constantin FF constantin...@gmail.com wrote: Is there a better way for doing that? There is something similar in other I haven't written anything that implied/suggested/required changing your existing interface, only your php code. function _sortPosts($newSort){ sort($newSort); foreach ($newSort AS $id = $value) { $this-Post-id = $id; $this-Post-moveDown(true); } ^That's what I suggested in your previous thread. if newSort is nested - adjust appropriately. AD -- 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: Slow reorder TreeBehaviour
Probably this could work but will be almost impossible to calculate the step for moveDown of each post also in this action are involved parents and children so in the $newSort each post is as post_id = order number. So if I do it like you suggested, first I will have to separate posts with same parent_id and then to moveDown each of them. On Oct 28, 12:23 pm, AD7six andydawso...@gmail.com wrote: On Oct 28, 11:16 am, Constantin FF constantin...@gmail.com wrote: Is there a better way for doing that? There is something similar in other I haven't written anything that implied/suggested/required changing your existing interface, only your php code. function _sortPosts($newSort){ sort($newSort); foreach ($newSort AS $id = $value) { $this-Post-id = $id; $this-Post-moveDown(true); } ^That's what I suggested in your previous thread. if newSort is nested - adjust appropriately. AD -- 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: Slow reorder TreeBehaviour
On Oct 28, 12:37 pm, Constantin.FF constantin...@gmail.com wrote: Probably this could work but will be almost impossible to calculate the step for moveDown _WHY_ would you need to calculate that? The suspicion arises that you aren't reading much of what I write. of each post also in this action are involved parents and children so in the $newSort each post is as post_id = order number. So if I do it like you suggested, first I will have to separate posts with same parent_id and then to moveDown each of them. Well I don't know what your interface is, but whatever it is the code you're writing, and the extra sort field, is not necessary to achieve what you're doing. Visually I'd implement what you're doing as 1) move everything on the screen 2) click the save button. It's not that hard. You might also just want to use a materialized path (add a field called position, store 1.1.1, 1.1.2, 1.1.3 in it and sort by this whenever you render your data). But I kind of give up trying to explain how to use the tree behavior... have fun. AD -- 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: Slow reorder TreeBehaviour
Thanks for the time and ideas. I continue working on both methods. On Fri, Oct 28, 2011 at 1:47 PM, AD7six andydawso...@gmail.com wrote: On Oct 28, 12:37 pm, Constantin.FF constantin...@gmail.com wrote: Probably this could work but will be almost impossible to calculate the step for moveDown _WHY_ would you need to calculate that? The suspicion arises that you aren't reading much of what I write. of each post also in this action are involved parents and children so in the $newSort each post is as post_id = order number. So if I do it like you suggested, first I will have to separate posts with same parent_id and then to moveDown each of them. Well I don't know what your interface is, but whatever it is the code you're writing, and the extra sort field, is not necessary to achieve what you're doing. Visually I'd implement what you're doing as 1) move everything on the screen 2) click the save button. It's not that hard. You might also just want to use a materialized path (add a field called position, store 1.1.1, 1.1.2, 1.1.3 in it and sort by this whenever you render your data). But I kind of give up trying to explain how to use the tree behavior... have fun. AD -- 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