Re: Filtering by related model...

2011-01-09 Thread Amit Badkas
Hi,

Could you please show me the structure of categories table. I need to know
surely if Product belongs to Category or Product has many Category or
Product has and belongs to many Category.

Amit Badkas

PHP Applications for E-Biz: http://www.sanisoft.com



On Sat, Jan 8, 2011 at 1:25 AM, TSG ke...@thatscriptguy.com wrote:

 I know I've read this somewhere, but I've been searching for an hour
 now and cannot find it.

 I have a Product model
 I have a Category model

 A product can have many categories

 The categories table has a field, slug, that is used for SEO purposes.

 I currently have a beautifully formatted, paginated list of my
 products at /products and that works just great.  But I need to be
 able to filter by the category slug (I'm thinking /products/category/
 my-slug-goes-here) and have it use my same view, just with the
 filtered data.

 How do I do this?  It is driving me absolutely nuts.  I know it's a
 simple thing, as the relationships are all set up in the models
 perfectly fine.  But for the life of me, I just can't get it to work.

 My index method:

 function index() {
$this-Product-recursive = 1;
$this-Product-contain('WordAd');
$this-set('products', $this-paginate());
}

 Can someone please help me with this?  I'm loving Cake so far.  It has
 greatly sped up my development.  I've just hit a snag.

 Thanks

 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


Filtering by related model...

2011-01-07 Thread TSG
I know I've read this somewhere, but I've been searching for an hour
now and cannot find it.

I have a Product model
I have a Category model

A product can have many categories

The categories table has a field, slug, that is used for SEO purposes.

I currently have a beautifully formatted, paginated list of my
products at /products and that works just great.  But I need to be
able to filter by the category slug (I'm thinking /products/category/
my-slug-goes-here) and have it use my same view, just with the
filtered data.

How do I do this?  It is driving me absolutely nuts.  I know it's a
simple thing, as the relationships are all set up in the models
perfectly fine.  But for the life of me, I just can't get it to work.

My index method:

function index() {
$this-Product-recursive = 1;
$this-Product-contain('WordAd');
$this-set('products', $this-paginate());
}

Can someone please help me with this?  I'm loving Cake so far.  It has
greatly sped up my development.  I've just hit a snag.

Thanks

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