Re: How to paginate HABTM relations

2011-01-11 Thread Andi
Hi,

I always have similar problems. With HABTM you have to join the tables
by yourself over the options-array.

Look here for the syntax:
http://book.cakephp.org/view/872/Joining-tables

This should also work with the pafinate method.

On 11 Jan., 02:29, Synue Cunioci srcuni...@gmail.com wrote:
 Hi everybody!

 Here is the thing: I have a table called tags and other six
 tables(informatives, courses, activities, events, documents and
 clippinngs) that has a a HABTM relation with the table tags.

 I have something that I call supertags. It´s a list of the 8 most
 tagged tag. This list contains a link to a method that receives the id
 of the tag and should return another list (an paginated one) with the
 entries of the other tables (informatives, courses, activities,
 events, documents and clippinngs) that have the relation with the tag.

 What I did at first was $this-Tag-find('first', array('conditions'
 = array('Tag.id' = '$id')), with recursive=1 and then manipulate the
 array.

 But then I discovered that the paginate() method needs the first
 params to be a model, and not an array.

 So I read a lot of posts about paginate and HABTM relations but since,
 I'm new at cake, I couldn't understand a bit. I think that the answer
 lies on something about afterFind and bind.

 So, can someone with a lot of patience explain to me how to join the
 tables and fetch the result paginated??

 Thanks in Advance!!

 PS: Cricket, if you see the post can you reply to me? You are the only
 one that replied my posts

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


How to paginate HABTM relations

2011-01-10 Thread Synue Cunioci
Hi everybody!

Here is the thing: I have a table called tags and other six
tables(informatives, courses, activities, events, documents and
clippinngs) that has a a HABTM relation with the table tags.

I have something that I call supertags. It´s a list of the 8 most
tagged tag. This list contains a link to a method that receives the id
of the tag and should return another list (an paginated one) with the
entries of the other tables (informatives, courses, activities,
events, documents and clippinngs) that have the relation with the tag.

What I did at first was $this-Tag-find('first', array('conditions'
= array('Tag.id' = '$id')), with recursive=1 and then manipulate the
array.

But then I discovered that the paginate() method needs the first
params to be a model, and not an array.

So I read a lot of posts about paginate and HABTM relations but since,
I'm new at cake, I couldn't understand a bit. I think that the answer
lies on something about afterFind and bind.

So, can someone with a lot of patience explain to me how to join the
tables and fetch the result paginated??

Thanks in Advance!!


PS: Cricket, if you see the post can you reply to me? You are the only
one that replied my posts

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