views:

33

answers:

2

Hi, I understood (more or less) the separation between the MVC parts in cakePhp, however i cannot understand what are the defaults. meaning:

What should i edit in order to change the root-entry-point of my site(the known "index.html" or "index.php" file, that shouldn't be changed in cake)?

What controller? What model? What view? What layout? (hope I'm understood) (i am using version 1.3)

thanks

A: 

What you should edit to modify the root is:

app\views\pages\home.ctp

The default layout can be tweaked here:

app\views\layouts\default.ctp

From there on you can create your menus, links etc to other controllers of other pages, then involving the traditional MVC patterns/conventions you already know.

Addition:

If you want to provide a link to your statistics then use for example:

echo $html->link('My nice statistics',
        array('controller' => 'statistics', 'action' => 'show'));

If you would like to embed the statistics then I would use elements: http://book.cakephp.org/view/1081/Elements.

I am not sure about what you missed: maybe the fact you can specify the controller to use for links if it is an external controller to the MVC scope currently used.

Are you sure you have understood the conventions behind MVC? Here is the tutorial I started with some time ago. It is well made but a bit out of date for cakephp 1.3. Nevertheless it illustrates the basic concepts very nicely: Cook web sites fast using CakePHP (IBM)

I hope this is more helpful then :-)

jdehaan
Thanks jdehaan - but this is actually the point that i am stuck.lets say that i want some statistics from my db to be shown in the homepage. what model should i use? what controller?is it something so trivial that i am the only one that can't see it? :)thanks again
yossi
I am not sure about what you misunderstood. The concepts are based on conventions based on naming what looks like magic if you are not used to such programming. This eases and speeds up development a lot. Of course some call paths become not so visible. I added some info to the answer. I hope this is more helpful.
jdehaan
Thanks - it is helpful indeed. now i need to dive in regarding the model.thanks again!
yossi
+1  A: 

The default Route in Cake routes the address / to the PagesController::display action with the parameter "home", which will make the Pages controller display the file /views/pages/home.ctp. If you just want a static home page, just edit that file.

If your default homepage at / should display more complex data, including model data, you would rather create your own controller with a model and its own directory in /views/ and change the default route for / in /app/config/routes.php to point to an action of that controller.

deceze
thank you very much
yossi