shopping cart widget or component or module ?

Hi all !

Im new to the yii framework and I am a bit confused about the diffrent avalible components.

So I will build a shopping cart that should be included on every page with an certain layout.

At the moment i have a basic controller that can be called with ajax from the productpage to add items to the cart.

and then do a renderpartial. this works fine but I cant include a call to a controller from a layout can I ??

so whats the best approach achiving what i want ?

I want a cart that displays on every page, but I also nedd the abilty to do ajax calls and render the cart with renderpartial.

Could someone chime in please.

As I understand you need an action that will return this cart (it will be in a div that will be updated with ajax).

I do not know if the view of this action can call a widget.

Also I thing this action’s view (if possible) will be rendered at the layout.

I hope to help.

I dont really understand what you are suggestion,

This is my setup so far

I have a cart object stored in the session db

I have a controller basket controller wich I can call from the project page with ajax

This controller adds the project to the cart object and then do a render partial. of the cart

from within the cart I also have functionality to remove update etc wich also do ajax calls to the basket controller.

My problem is now the cart is not rendered without an ajax call, and I want it to be displyed on every page without the need of first doing an ajax call thats update the div.

was that any clearer ?

Thanks for your time

So why you don make a widget or a view to show your cart?

Can I make a POST to a widget ? might be a stupid question but I have not seen that anywhere?

I need to post when making ajax calls both from within the dcart and from the outside eg the product page.

You want to show your cart at your page so you have to make a view that will be rendering at layout.

You also can attach this view to a action that will make whatever you want.

Is that fit you?

so what you are saying is that I can share the view between the widget and a controller

eg they will use the same view file.

Could you please provide some examples on how to do that and I will be very grateful.


You may read this, it is just a view rendering at a controller and at layout I thing will be with renderpartial even I did not try it.