On 23-Jan-2007, at 21:29, c46 wrote:

What I need to do is keep the user on the same page even after adding
product(s) to the cart i.e. the user views the product listing, clicks
the 'add to cart' button for one of the products, and the same page
refreshes with the updated cart.

The issue I'm running into is that the action ('addtocart') in the
controller is obviously looking for a view with the same name, which
doesn't exist. One way I could possibly hack it is to set a hidden
field with the url and then redirect back to it at the end of the
action. But there has to be a better way...

I asume that the URL of the cart (/shopping_carts/show/44 or whatever) can be assembled from data in the addToCart action? If so then you can do the redirect without setting a hidden field.

function addToCart ($cartId, $itmId)
{
        // validate input, add item to cart...

        $this->redirect("/shopping_carts/show/{$cartId});
        return true;
}

s.

Attachment: PGP.sig
Description: This is a digitally signed message part

Reply via email to