Re: Paginate HABTM in the views question.

2008-01-19 Thread fr3nch13

Ok, i found a solution to this and submitted a diff for it:

https://trac.cakephp.org/ticket/1903#comment:10

This should allow proper pagination of a HABTM associated model on the
main model's view .ctp file

Let me know what you guys think.

On Jan 19, 12:16 pm, fr3nch13 <[EMAIL PROTECTED]> wrote:
> seems like this isn't a new issue:
>
> https://trac.cakephp.org/ticket/1903
>
> On Jan 19, 10:41 am, fr3nch13 <[EMAIL PROTECTED]> wrote:
>
> > I looked over group, blogs, bakery, api, code, etc. and i can't seem
> > to figure this one out.
>
> > I'm paginating like suggested 
> > here:http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-...
>
> > But where the article ends/is missing is what do you do in your view?
>
> > Specifically, if you look below at the code from my view, I would
> > assume that "User.name" would work, and it does as far as sorting by
> > the correct field, but the direction is always "asc", it never
> > changes. I dont have enough records in my database yet to go over 1
> > page, so i don't know if this affects the page numbers as well.
>
> > My views/users/category.ctp
>
> > sort(__r('Name'), 'User.name');?>
> >  __r() is a wrapper so i dont have to type 'true'
>
> > Any help is appreciated.
>
> > P.S. I assumed this based on the above article:
>
> > My models/user.php
> > class User extends AppModel {
> > var $hasAndBelongsToMany = array('Category' => array('with' =>
> > 'CategoriesUser'));
>
> > }
>
> > My controllers/users_controller.php
> > class UsersController extends AppController {
> > // called via ajax from categories/view
> > function category($category_id = null)
> > {
> > if ($category_id)
> > {
> > //$this->paginateHolder();
> > $users = $this->paginate('CategoriesUser',
> > array('Category.id'=>$category_id));
> > $this->set('users', $users);
> > }
> > $this->layout = 'ajax';
> > }
>
> > }
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Paginate HABTM in the views question.

2008-01-19 Thread fr3nch13

seems like this isn't a new issue:

https://trac.cakephp.org/ticket/1903

On Jan 19, 10:41 am, fr3nch13 <[EMAIL PROTECTED]> wrote:
> I looked over group, blogs, bakery, api, code, etc. and i can't seem
> to figure this one out.
>
> I'm paginating like suggested 
> here:http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-...
>
> But where the article ends/is missing is what do you do in your view?
>
> Specifically, if you look below at the code from my view, I would
> assume that "User.name" would work, and it does as far as sorting by
> the correct field, but the direction is always "asc", it never
> changes. I dont have enough records in my database yet to go over 1
> page, so i don't know if this affects the page numbers as well.
>
> My views/users/category.ctp
>
> sort(__r('Name'), 'User.name');?>
>  __r() is a wrapper so i dont have to type 'true'
>
> Any help is appreciated.
>
> P.S. I assumed this based on the above article:
>
> My models/user.php
> class User extends AppModel {
> var $hasAndBelongsToMany = array('Category' => array('with' =>
> 'CategoriesUser'));
>
> }
>
> My controllers/users_controller.php
> class UsersController extends AppController {
> // called via ajax from categories/view
> function category($category_id = null)
> {
> if ($category_id)
> {
> //$this->paginateHolder();
> $users = $this->paginate('CategoriesUser',
> array('Category.id'=>$category_id));
> $this->set('users', $users);
> }
> $this->layout = 'ajax';
> }
>
> }
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Paginate HABTM in the views question.

2008-01-19 Thread fr3nch13

I looked over group, blogs, bakery, api, code, etc. and i can't seem
to figure this one out.

I'm paginating like suggested here:
http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/

But where the article ends/is missing is what do you do in your view?

Specifically, if you look below at the code from my view, I would
assume that "User.name" would work, and it does as far as sorting by
the correct field, but the direction is always "asc", it never
changes. I dont have enough records in my database yet to go over 1
page, so i don't know if this affects the page numbers as well.

My views/users/category.ctp

sort(__r('Name'), 'User.name');?>
 __r() is a wrapper so i dont have to type 'true'

Any help is appreciated.

P.S. I assumed this based on the above article:

My models/user.php
class User extends AppModel {
var $hasAndBelongsToMany = array('Category' => array('with' =>
'CategoriesUser'));
}

My controllers/users_controller.php
class UsersController extends AppController {
// called via ajax from categories/view
function category($category_id = null)
{
if ($category_id)
{
//$this->paginateHolder();
$users = $this->paginate('CategoriesUser',
array('Category.id'=>$category_id));
$this->set('users', $users);
}
$this->layout = 'ajax';
}
}

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---