views:

469

answers:

1

Hi,

I´m starting to developing with cake php. I have designed a DB model and baked my mvc´s.

Now i want a index / home site. This site should be an overview of possible actions which a user can do.

Should I use an app_controller for that or route to an existing controller even if that controller has nothing to do with a home site, or should I use a separate controller with no model just for displaying the overview and edit the route of / to point at this new Home Controller?

Whats the best practice for that?

+5  A: 

Your question is a little vague to me. I am going to assume that by "site" you mean "page".

If by "overview of possible actions which a user can do" you mean a static page with links, then use the provided PagesController, and create a view at app/views/pages/home.ctp.

If by "overview of possible actions which a user can do" you mean a dynamic page with links and data, then create a controller action to feed the page the correct data.

Where that controller action goes should depend on where the data comes from.

If it lists the latest posts, create a PostsController::home() action.

If it needs data from the User model in order to determine what to display, then create a UsersController::home() action.

Finally, if you are mixing data from many models with no clear winner, or you are actually creating a home "site" instead of a "page", create a HomeController or DashboardController.

Read this post by teknoid for a nice succinct way of loading in arbitrary models when needed.

deizel
Forgot to add: Yes, you should use routing to redirect `/` to the controller action of your choice.
deizel
thx nice overview
Richard