On 7/4/06, Ryan Ginstrom <[EMAIL PROTECTED]> wrote:
>
> > [mailto:[EMAIL PROTECTED] On Behalf Of ShepherdWeb
> > That makes sense.  My current implementation is the other way around
> > though:
> >
> > (my url looks like this: /products/color/<color_id>)
>
> So...
>
> In colors_controller:
>
> function getById( $id )
> {
>    $this->Color->id = $id ;
>    return $this->Color->read() ;
> }
>
> In products_controller:
>
> function color( $id )
> {
>    $this->set( 'data', $this->requestAction( "/colors/getById/$id" ) ) ;
> }

if you're after the colour, you could also get it like so:

// in products_controller.php

function color ($name)
{
    // set id for color
    $this->Product->Color->id = $id;
    // set recursive var for Color model so it pulls proper product details in
    $this->Product->Color->recursive = 2;
    // find color details (and associated models
    $color = $this->Product->Color->find();
}


this should output something along the lines of:

[Color] => Array (
                        [id] => 2
                        [name] => Lime
                        [hex] => 3beb63
                        [Product][0] => Array (
                        [id] => 2
                        [title] => Another Test Product
                        [description] => some more description and stuff yeah 
yeah yay
                        [inventory] => 15
                        [price] => 3.49
                        [color_id] => 2 )
                        [Product] => Array (
                        [id] => 5
                        [title] => Green Headband
                        [description] => this is a nice green headband
                        [inventory] => 3
                        [price] => 2.54
                        [color_id] => 2 )
                        )

hth

jon


-- 


jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to