On Thu, Oct 14, 2010 at 5:11 AM, Tomfox Wiranata
<[email protected]> wrote:
> Hi,
>
> this cry for help might seem weird. on my homepage are product sites.
> user clicks on a link to get to product "abc". this is how the link
> looks like :
>
> echo $html->image($product['Product']['flyer_path_thumb'], array(
> "alt" =>$product['Product']['title'],
> 'url' => array('controller' => 'products', 'action' =>
> 'view',
> $product['Product']['id'])
> ));
>
> the URL then looks like this: ....products/view/id_of_abc
>
> as you can see I pass this products ID to the controller "products"
> and action "view" and use the ID to retrieve the data for "abc" from
> my database. and this is the action that gets all information about
> the product from the database:
>
> function view($id = null)
> {
> $this->Product->id = $id;
> $pr = $this->Product->find(bla bla bla Product.id = $id);
> }
>
>
> it works fine. but I need to find a different way to pass the ID to
> the controller action. because It interrupts jquery sending data to
> another action in this controller. and it does not matter if I send
> via GET or POST, and/or .load() or .ajax(). as long as I pass the ID
> like mentioned above, i cant pass data with jquery....
>
> so is there another way to pass the product ID to the action, when
> user clicks the link?
You could wish upon a star. Why not just create a route and pass the id?
Router::connect(
'/products/view/:id',
array('controller' => 'products', 'action' => 'view'),
array('id' => '[0-9]+', 'pass' => array('id'))
);
Or even:
Router::connect(
'/products/:id',
array('controller' => 'products', 'action' => 'view'),
array('id' => '[0-9]+', 'pass' => array('id'))
);
But you'd need to be careful where you place that one. What does the
JQuery request URL look like? If you create the above route, and
another for the other request, you should be fine. It all depends on
how the route URLs look and how they're situated in routes.php with
respect to each other.
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 [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?hl=en