开发者

What are the defaults(homepage,controller,etc..) for cakePhp?

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" f开发者_高级运维ile, 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


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 :-)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜