maxmilian
(Andreas Strahle)
September 30, 2009, 8:50am
1
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.
dimis283
(Dimis283)
September 30, 2009, 10:15am
2
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.
maxmilian
(Andreas Strahle)
September 30, 2009, 10:36am
3
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
dimis283
(Dimis283)
September 30, 2009, 10:47am
4
So why you don make a widget or a view to show your cart?
maxmilian
(Andreas Strahle)
September 30, 2009, 12:02pm
5
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.
dimis283
(Dimis283)
September 30, 2009, 12:23pm
6
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?
maxmilian
(Andreas Strahle)
September 30, 2009, 12:36pm
7
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.
thanks
dimis283
(Dimis283)
September 30, 2009, 3:18pm
8
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.