Re: Pagination with HABTM?

2012-06-25 Thread 42startups
Yep, doesn't seem to work as it returns all the posts.


On Monday, June 25, 2012 3:21:15 PM UTC+10, Борислав Събев wrote:

 Have you tried configuring the paginator in your Controller with a limit 
 of 10:

 public $paginate = array(
 'limit' = 10,
 'order' = array(
 'Post.title' = 'asc'
 )
 );



 On Monday, 25 June 2012 04:14:32 UTC+3, 42startups wrote:

 Ah ok, so how would I paginate and limit results to 10?...

 $this-loadModel('Tag', $id);
 $tag = $this-Tag-read();

 On Monday, June 25, 2012 6:11:55 AM UTC+10, JonStark wrote:

 I find it easier to use LoadModel to display and sort posts from HABTM...

 Le dimanche 24 juin 2012 10:40:04 UTC+2, 42startups a écrit :

 Wow, CakePHP really hasn't got this problem sorted.

 After hours of searching I came across the solution below (which may or 
 may not be outdated), but I'm having issues applying paginatior 'limit' = 
 10 or other ordering.

 Any ideas what I'm missing?

 My model:

 public $hasAndBelongsToMany = array(
 'Post' = array(
 'className'  = 'Post',
 'joinTable'  = 'tags_posts',
 'foreignKey' = 'tag_id',
 'associationForeignKey'  = 'post_id',  
 'order'  = array('Post.created DESC'),
 'unique' = true
 )
 );

 In my controller in view()

 public function view($id) {
 $this-Tag-bindModel(array('hasOne' = array('TagsPost')), false);
  
 $this-set('tag', $this-paginate('Tag', array('TagsPost.tag_id' = 
 $id))); 
 }

 In my view I then had to change:

 foreach ($tag['Post'] as $post)

 to

 foreach ($tag[0]['Post'] as $post)



-- 
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: Pagination with HABTM?

2012-06-25 Thread JonStark
Yes, I do it this way in my app:

$this-loadModel('Post');
$this-paginate = array('Post' = array('conditions' = //conditions ), 
'limit' = '8', 'order' = array('Post.created' = 'desc')));
$data = $this-paginate('Post');
$this-set('posts', $data);


Hope it helped

Le lundi 25 juin 2012 03:14:32 UTC+2, 42startups a écrit :

 Ah ok, so how would I paginate and limit results to 10?...

 $this-loadModel('Tag', $id);
 $tag = $this-Tag-read();

 On Monday, June 25, 2012 6:11:55 AM UTC+10, JonStark wrote:

 I find it easier to use LoadModel to display and sort posts from HABTM...

 Le dimanche 24 juin 2012 10:40:04 UTC+2, 42startups a écrit :

 Wow, CakePHP really hasn't got this problem sorted.

 After hours of searching I came across the solution below (which may or 
 may not be outdated), but I'm having issues applying paginatior 'limit' = 
 10 or other ordering.

 Any ideas what I'm missing?

 My model:

 public $hasAndBelongsToMany = array(
 'Post' = array(
 'className'  = 'Post',
 'joinTable'  = 'tags_posts',
 'foreignKey' = 'tag_id',
 'associationForeignKey'  = 'post_id',  
 'order'  = array('Post.created DESC'),
 'unique' = true
 )
 );

 In my controller in view()

 public function view($id) {
 $this-Tag-bindModel(array('hasOne' = array('TagsPost')), false); 
 $this-set('tag', $this-paginate('Tag', array('TagsPost.tag_id' = 
 $id))); 
 }

 In my view I then had to change:

 foreach ($tag['Post'] as $post)

 to

 foreach ($tag[0]['Post'] as $post)



-- 
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: Pagination with HABTM?

2012-06-24 Thread JonStark
I find it easier to use LoadModel to display and sort posts from HABTM...

Le dimanche 24 juin 2012 10:40:04 UTC+2, 42startups a écrit :

 Wow, CakePHP really hasn't got this problem sorted.

 After hours of searching I came across the solution below (which may or 
 may not be outdated), but I'm having issues applying paginatior 'limit' = 
 10 or other ordering.

 Any ideas what I'm missing?

 My model:

 public $hasAndBelongsToMany = array(
 'Post' = array(
 'className'  = 'Post',
 'joinTable'  = 'tags_posts',
 'foreignKey' = 'tag_id',
 'associationForeignKey'  = 'post_id',  
 'order'  = array('Post.created DESC'),
 'unique' = true
 )
 );

 In my controller in view()

 public function view($id) {
 $this-Tag-bindModel(array('hasOne' = array('TagsPost')), false); 
 $this-set('tag', $this-paginate('Tag', array('TagsPost.tag_id' = 
 $id))); 
 }

 In my view I then had to change:

 foreach ($tag['Post'] as $post)

 to

 foreach ($tag[0]['Post'] as $post)



-- 
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: Pagination with HABTM?

2012-06-24 Thread 42startups
Ah ok, so how would I paginate and limit results to 10?...

$this-loadModel('Tag', $id);
$tag = $this-Tag-read();

On Monday, June 25, 2012 6:11:55 AM UTC+10, JonStark wrote:

 I find it easier to use LoadModel to display and sort posts from HABTM...

 Le dimanche 24 juin 2012 10:40:04 UTC+2, 42startups a écrit :

 Wow, CakePHP really hasn't got this problem sorted.

 After hours of searching I came across the solution below (which may or 
 may not be outdated), but I'm having issues applying paginatior 'limit' = 
 10 or other ordering.

 Any ideas what I'm missing?

 My model:

 public $hasAndBelongsToMany = array(
 'Post' = array(
 'className'  = 'Post',
 'joinTable'  = 'tags_posts',
 'foreignKey' = 'tag_id',
 'associationForeignKey'  = 'post_id',  
 'order'  = array('Post.created DESC'),
 'unique' = true
 )
 );

 In my controller in view()

 public function view($id) {
 $this-Tag-bindModel(array('hasOne' = array('TagsPost')), false); 
 $this-set('tag', $this-paginate('Tag', array('TagsPost.tag_id' = 
 $id))); 
 }

 In my view I then had to change:

 foreach ($tag['Post'] as $post)

 to

 foreach ($tag[0]['Post'] as $post)



-- 
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: Pagination with HABTM?

2012-06-24 Thread Борислав Събев
Have you tried configuring the paginator in your Controller with a limit of 
10:

public $paginate = array(
'limit' = 10,
'order' = array(
'Post.title' = 'asc'
)
);



On Monday, 25 June 2012 04:14:32 UTC+3, 42startups wrote:

 Ah ok, so how would I paginate and limit results to 10?...

 $this-loadModel('Tag', $id);
 $tag = $this-Tag-read();

 On Monday, June 25, 2012 6:11:55 AM UTC+10, JonStark wrote:

 I find it easier to use LoadModel to display and sort posts from HABTM...

 Le dimanche 24 juin 2012 10:40:04 UTC+2, 42startups a écrit :

 Wow, CakePHP really hasn't got this problem sorted.

 After hours of searching I came across the solution below (which may or 
 may not be outdated), but I'm having issues applying paginatior 'limit' = 
 10 or other ordering.

 Any ideas what I'm missing?

 My model:

 public $hasAndBelongsToMany = array(
 'Post' = array(
 'className'  = 'Post',
 'joinTable'  = 'tags_posts',
 'foreignKey' = 'tag_id',
 'associationForeignKey'  = 'post_id',  
 'order'  = array('Post.created DESC'),
 'unique' = true
 )
 );

 In my controller in view()

 public function view($id) {
 $this-Tag-bindModel(array('hasOne' = array('TagsPost')), false); 
 $this-set('tag', $this-paginate('Tag', array('TagsPost.tag_id' = 
 $id))); 
 }

 In my view I then had to change:

 foreach ($tag['Post'] as $post)

 to

 foreach ($tag[0]['Post'] as $post)



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