CodeIgniter Forums

Full Version: Get back where you where with same var.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]sikkle[/eluser]
Hi,

i'm wondering how to handle this in any elegant way.


If you have a garage, get some car in the garage, and get some details about each piece of your car have.

That mean,

Garage table (ID of garage and Link to UserId)
Car table (Link to ID of garage)
Piece (Link to car id) (Maybe link to garage too ??)

If you have like

Garage controller and view to show garage from one particular user.

Selection of garage id number #18, so opening controller CAR, and view of listing of the car in this garage.

You keep going, Select any car to see piece detail, Piece Controller and View to show list of Pieces rely to the selected car.

Select a piece, edit, save and go to kind of Save_Piece_Success.

At this point you want to get back at the piece listing.

How do i preserve the CAR id to show this list.

I'm looking for some suggestion.

thanks !

El Forum

[eluser]coolfactor[/eluser]
It sounds like you're bringing the definition of a "controller" from another framework? You don't need one controller per table. Controllers define sections of your site (related groups of pages), so you might have a single Shop controller with methods for viewing a garage, listing cars in a particular garage, listing parts for a car, and so on.

I use functions like:

- garage_view() - show details of garage
- garage_edit() - edit details of garage
- garage_save() - save changes for garage

- car_view() - show details for car (list all parts, etc.)
- car_edit() - edit details of car
- car_save() - save changes to car

Normally, the save() functions redirect back to the view() function when they are done (using a browser redirect). If you need them to do something depending on which button was clicked, then provide different Submit buttons, and have the save() function detect which submit button was clicked, and then take appropriate action.

Does that get your started?

El Forum

[eluser]sikkle[/eluser]
Ho my god, if i operate this on the same controller, that mean i can just use and keep the same Var in the $__POST this is it ?

Ok, so i mean, you'll manage the garage_view to show list of car in the garage, so list the garage with id 16.

After this you'll pick up a car, maybe the #76, but this is it, if you can edit Piece direclty, i mean modify the piece, and get back to the car and after to the good garage.

Like

garage_view() -> car_view() -> piece_view() -> piece_edit() ->
piece_save() -> piece_view -> car_view -> garage_view()

In the process like piece_view, i'll make the piece listing for this car, so my return button, how do you manage to make go through the garage ID to get back on the good listing at the end ?.

Sorry if this appear weird, but i'm learning a lot already with what you tell me Smile

many thanks

El Forum

[eluser]coolfactor[/eluser]
Here's how I would approach this:

1. mock up your various pages.
2. then assign urls to those pages. These urls will determine your controller and function names, and you can begin to map the "flow" from one page to the next.

Example: editing a car - when you click "Save" where will you go next?

You might have /admin/car_edit/<car_id>/ as your url. That tells you that "admin" is your controller, and "car_edit" is your function. <car_id> is the first parameter to that function.

Start simple and build from there. Don't try to understand it all at once.

El Forum

[eluser]sikkle[/eluser]
yea, i already done this, but not in MVC basis and Not with Code igniter.

I always prevent to use any ID in the URI, maybe i'm a little old school now Wink

i'm always pass it by any post statement, to didnt show anytings on the uri.

I think for this kind of case, with Ci i'll have no choice and this is the right way to do this huh?

many thanks again.