Re: CakePHP 2.6.X Pagination Sort Errors
As luck would have it, after completing more section it started functioning properly. Very strange that an error like this would simply disappear... I have noticed that by using the sort function that it does not maintain pretty url's. It's uses /admin/pages?sort=Page.idorder=asc -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
CakePHP 2.6.X Pagination Sort Errors
I am faced a new issues regarding CakePHP 2.6.X and pagination; I've never had this issue before and it only happens when attempting to use $this-Paginator-sort(...) in a view. $this-Paginator-sort('Page.id', 'ID', array('model' = 'Page')); $this-Paginator-sort('Page.id', 'ID'); $this-Paginator-sort('id'); I've done the normal setup of the pagination object in the controller $this-Paginator-settings = array( 'contain' = false, 'group' = 'Page.id', 'order' = 'Page.name ASC', 'limit' = 20 ); $results = $this-Paginator-paginate('Page'); I am getting this in the view file Warning (2): array_filter() expects parameter 1 to be array, null given [ CORE/Cake/View/Helper/PaginatorHelper.php, line 435] Warning (2): array_merge() [function.array-merge]: Argument #1 is not an array [CORE/Cake/View/Helper/PaginatorHelper.php, line 435] Upon tracking the issue it stems from the params function on line 126 in the pagination helper, on line 131 it is returning null because request-params['paging'] is null. if (!isset($this-request-params['paging']) || empty($this-request-params ['paging'][$model])) { return null; } With the above explained, why is request-params['paging'] null? Shouldn't it be populated with information as it is in other sections? Is the sort function broken or am I missing something? Any help would be greatly appreciated. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Pagination Sort, Resetting Data
Hello, I just starting baking with CakePHP and I'm slowly grasping the basics. So far I've created a view to display all the data in table format from a table in the database with pagination. There is a column in the table that contains browser information (Firefox, Chrome, Safari...etc). So on the view I made some checkboxes using Form-checkbox, with each check box representing a browser. When the the submit button is pressed, the POST request is sent to the searchByBrowser function in the controller and the view is updated with the appropiate data. Now I am adding sort() functionality using Paginator-sort() and it sorts by the specified column just fine. However, when I use the searchByBrower function to get the appropiate view and then try and sort the displayed data, it resets everything to showing all the full dataset and the checkbox is no longer checked. Is there a way to get everything to work the way it should with just CakePHP? Thanks. https://lh5.googleusercontent.com/-LCH0weRW-7I/Uw67CrrwNYI/AL0/BheSsX7F6CM/s1600/2.png 1 - Full data set view https://lh5.googleusercontent.com/-0s4vsxnDZ_Q/Uw67Fc0t-SI/AL8/vxPjY_HSK4E/s1600/3.png 2 - Just Firefox data https://lh3.googleusercontent.com/-yDNtPKrJf3I/Uw66_loiPYI/ALs/qUYZso_zCcg/s1600/1.png 3 - Sorted on http_method, full dataset again (instead of just firefox data) -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: Pagination Sort, Resetting Data
你是用 Paginator-sort() 產生的連結(我知道這裡你把它變成checkbox了),再點擊它的時候,已經不是 post request; 但取而代之是傳入 querystring 或是 named parameters,這時候你的 searchByBrowser 應該要在接收到這些與sort有關的參數時, 最後要再指定給 $this-request-data,這樣 view 在被 rendering 的時候就會把 request data 的值填回你的 Form 表單。 Eric Chan eric.hf.c...@gmail.com 於 2014/2/27 下午12:14 寫道: Hello, I just starting baking with CakePHP and I'm slowly grasping the basics. So far I've created a view to display all the data in table format from a table in the database with pagination. There is a column in the table that contains browser information (Firefox, Chrome, Safari...etc). So on the view I made some checkboxes using Form-checkbox, with each check box representing a browser. When the the submit button is pressed, the POST request is sent to the searchByBrowser function in the controller and the view is updated with the appropiate data. Now I am adding sort() functionality using Paginator-sort() and it sorts by the specified column just fine. However, when I use the searchByBrower function to get the appropiate view and then try and sort the displayed data, it resets everything to showing all the full dataset and the checkbox is no longer checked. Is there a way to get everything to work the way it should with just CakePHP? Thanks. 1 - Full data set view 2 - Just Firefox data 3 - Sorted on http_method, full dataset again (instead of just firefox data) -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Pagination-sort associated Model
Hello, I use cakephp 2.3.4 When I use paginator-sort on a field of model default I have no problem. But if I want to sort on a field associated, sorting is the default. I use the code: $this-Paginator-sort(Model.NOM','HeaderName') when I look at $ this- params is what I get, you can see it at the attach file Thank for your help -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out. params = array( 'plugin' = null, 'controller' = 'defaultModels', 'action' = 'index', 'named' = array( 'sort' = 'newModel.NOM', 'direction' = 'asc' ), 'pass' = array(), 'isAjax' = false, 'paging' = array( 'defaultModel' = array( 'page' = (int) 1, 'current' = (int) 15, 'count' = (int) 40, 'prevPage' = false, 'nextPage' = true, 'pageCount' = (int) 3, 'order' = array( 'defaultModel.NOM' = 'asc' ), 'limit' = (int) 15, 'options' = array( 'order' = array( 'defaultModel.NOM' = 'asc' ), 'sort' = 'newModel.NOM', 'direction' = 'asc' ), 'paramType' = 'named' ) ), 'models' = array( 'defaultModel' = array( 'plugin' = null, 'className' = 'defaultModel' ), 'newModel' = array( 'plugin' = null, 'className' = 'newModel' ) ) )
Re: Pagination: Sort by count of related model (e.g. User - Posts)
Depending on how precise your information should be you can add a number_of_posts field to your users table and update the count periodically, you can also keep the field updated with database triggers, or create an action to run the update query from cakephp admin pages on demand. That's just another way of dealing with it. Regards On 13 jun, 13:11, DigitalDude e.blumsten...@googlemail.com wrote: Hey, I have a problem here and need to fix it. It's about the following situation: I have a model User that has a relation to some entrie, let's say Posts. I want to paginate the User-Model and add a counting of the user's posts to my index of Users. So I will have the following table- structure in my view: Id Name Posts Actions 2 Ben 5 view/edit/delete 5 Mary 8 view/edit/delete The first two columns are easy to sort, but HOW can I sort my paginated user-array by the count of the related Post-entries? I would really appreciate some help here, because I just cannot find a way to do this... :( Regards, DD 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Pagination: Sort by count of related model (e.g. User - Posts)
Hey, I have a problem here and need to fix it. It's about the following situation: I have a model User that has a relation to some entrie, let's say Posts. I want to paginate the User-Model and add a counting of the user's posts to my index of Users. So I will have the following table- structure in my view: Id Name Posts Actions 2 Ben 5 view/edit/delete 5 Mary8 view/edit/delete The first two columns are easy to sort, but HOW can I sort my paginated user-array by the count of the related Post-entries? I would really appreciate some help here, because I just cannot find a way to do this... :( Regards, DD 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Pagination: Sort by count of related model (e.g. User - Posts)
Ideally, you should be able to create post_count as a virtualField and then sort by that, by as the cookbook states, the paginator can't order by virtualFields of associated models, so you wouldn't be able to sort by it. But there are two simple workarounds for this: http://book.cakephp.org/view/1608/Virtual-fields On Jun 13, 4:11 am, DigitalDude e.blumsten...@googlemail.com wrote: Hey, I have a problem here and need to fix it. It's about the following situation: I have a model User that has a relation to some entrie, let's say Posts. I want to paginate the User-Model and add a counting of the user's posts to my index of Users. So I will have the following table- structure in my view: Id Name Posts Actions 2 Ben 5 view/edit/delete 5 Mary 8 view/edit/delete The first two columns are easy to sort, but HOW can I sort my paginated user-array by the count of the related Post-entries? I would really appreciate some help here, because I just cannot find a way to do this... :( Regards, DD 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Pagination: Sort by count of related model (e.g. User - Posts)
Would using the belongsTo models counterCache not be a better solution, so that it will not be necessary to perform the counting every time the users are listed with the post count? Mentioned in the CakePHP book at: http://book.cakephp.org/view/1042/belongsTo Enjoy, John On Jun 13, 3:42 pm, calvin cal...@rottenrecords.com wrote: Ideally, you should be able to create post_count as a virtualField and then sort by that, by as the cookbook states, the paginator can't order by virtualFields of associated models, so you wouldn't be able to sort by it. But there are two simple workarounds for this:http://book.cakephp.org/view/1608/Virtual-fields [snip] 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Pagination Sort
Hi guys, I have this model Structure - Model 1 - Union var $belongsTo = array( 'Address' = array( 'className' = 'Address', 'foreignKey' = 'address_id', 'conditions' = '', 'fields' = '', 'order' = '' ) ); Model 2 - Address var $belongsTo = array( 'District' = array( 'className' = 'District', 'foreignKey' = 'district_id', 'conditions' = '', 'fields' = '', 'order' = '' ) ); Model 3 District. with fields name and code both varchar. Now I would like to paginate the Unions which should be ordered in ASC by Union.Address.District.name ASC Is that possible and if so how should i write the paginate. Urgent help need. I am stuck here. Regards, -- Sijo Jose Chakramakkil 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Pagination Sort
I believe paginate documentation in the book has a similar example. On Tue, May 4, 2010 at 9:48 AM, sijo jose jose.s...@gmail.com wrote: Hi guys, I have this model Structure - Model 1 - Union var $belongsTo = array( 'Address' = array( 'className' = 'Address', 'foreignKey' = 'address_id', 'conditions' = '', 'fields' = '', 'order' = '' ) ); Model 2 - Address var $belongsTo = array( 'District' = array( 'className' = 'District', 'foreignKey' = 'district_id', 'conditions' = '', 'fields' = '', 'order' = '' ) ); Model 3 District. with fields name and code both varchar. Now I would like to paginate the Unions which should be ordered in ASC by Union.Address.District.name ASC Is that possible and if so how should i write the paginate. Urgent help need. I am stuck here. Regards, -- Sijo Jose Chakramakkil 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+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Pagination Sort
Check out the 2 links below: http://book.cakephp.org/view/164/Pagination http://book.cakephp.org/view/858/Using-Containable-with-pagination On Tue, May 4, 2010 at 11:07 AM, Andrei Mita andrei.m...@gmail.com wrote: I believe paginate documentation in the book has a similar example. On Tue, May 4, 2010 at 9:48 AM, sijo jose jose.s...@gmail.com wrote: Hi guys, I have this model Structure - Model 1 - Union var $belongsTo = array( 'Address' = array( 'className' = 'Address', 'foreignKey' = 'address_id', 'conditions' = '', 'fields' = '', 'order' = '' ) ); Model 2 - Address var $belongsTo = array( 'District' = array( 'className' = 'District', 'foreignKey' = 'district_id', 'conditions' = '', 'fields' = '', 'order' = '' ) ); Model 3 District. with fields name and code both varchar. Now I would like to paginate the Unions which should be ordered in ASC by Union.Address.District.name ASC Is that possible and if so how should i write the paginate. Urgent help need. I am stuck here. Regards, -- Sijo Jose Chakramakkil 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+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Pagination Sort
Well thanks for the prompt reply I have this model Structure - Model 1 - Union var $belongsTo = array( 'Address' = array( 'className' = 'Address', 'foreignKey' = 'address_id', 'conditions' = '', 'fields' = '', 'order' = '' ) ); Model 2 - Address var $belongsTo = array( 'District' = array( 'className' = 'District', 'foreignKey' = 'district_id', 'conditions' = '', 'fields' = '', 'order' = '' ) ); Model 3 District. with fields name and code both varchar. Now when I paginate UNION like this $this-paginate = array( 'order' = array('Address.street' = 'ASC'), ); it works fine. What I need is the next level that is District which is related to Address, but not to UNION On Tue, May 4, 2010 at 1:39 PM, Andrei Mita andrei.m...@gmail.com wrote: Check out the 2 links below: http://book.cakephp.org/view/164/Pagination http://book.cakephp.org/view/858/Using-Containable-with-pagination On Tue, May 4, 2010 at 11:07 AM, Andrei Mita andrei.m...@gmail.comwrote: I believe paginate documentation in the book has a similar example. On Tue, May 4, 2010 at 9:48 AM, sijo jose jose.s...@gmail.com wrote: Hi guys, I have this model Structure - Model 1 - Union var $belongsTo = array( 'Address' = array( 'className' = 'Address', 'foreignKey' = 'address_id', 'conditions' = '', 'fields' = '', 'order' = '' ) ); Model 2 - Address var $belongsTo = array( 'District' = array( 'className' = 'District', 'foreignKey' = 'district_id', 'conditions' = '', 'fields' = '', 'order' = '' ) ); Model 3 District. with fields name and code both varchar. Now I would like to paginate the Unions which should be ordered in ASC by Union.Address.District.name ASC Is that possible and if so how should i write the paginate. Urgent help need. I am stuck here. Regards, -- Sijo Jose Chakramakkil 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+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en 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+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en -- Sijo Jose Chakramakkil 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Pagination sort() tweaks
I was curious if anyone would like to comment on these few changes I've made to the pagination helper. I've noticed that regardless everything is always sorted asc, which for me didn't work as I need to be able to sort asc or desc from links next to the field names. (EG: Name (Asc) | (Desc)) So in order to do this, I pilfered through the pagination helper and tweaked it a little bit. function sort($title, $key = null, $options = array()) { $options = am(array('url' = array(), 'model' = null, 'dir' = null), $options); $url = $options['url']; unset($options['url']); if (empty($key)) { $key = $title; $title = Inflector::humanize(preg_replace('/_id$/', '', $title)); } if (isset($options['dir'])) { $dir = $options['dir']; unset($options['dir']); } elseif ($this-sortKey($options['model']) == $key $this- sortDir($options['model']) == 'asc') { $dir = 'desc'; } if (isset($options['model'])) { $key = $options['model'].'.'.$key; unset($options['model']); } $url = am(array('sort' = $key, 'direction' = $dir), $url, array('order' = null)); return $this-link($title, $url, $options); } Basically just added the dir option, and the ability to append the key with the model name sense currently in 1.2 it doesn't appear to accept the model option. By accept I mean actually perform something, from what I've seen prior to my changes it would sort by default.name instead of say, state.name. very odd considering that this should work? ?php echo $paginator-sort('blah', 'name', array('dir' = 'desc', 'model' = 'Business'));? But apparently doesn't. Thanks, Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---