Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a default controller for the index page for a CakePHP installation?

Tags:

cakephp

I have just successfully installed CakePHP and I see that I can edit the home.ctp view but is there a default controller for the index page?

To change the content of this page, create: APP/views/pages/home.ctp.
To change its layout, create: APP/views/layouts/default.ctp.
You can also add some CSS styles for your pages at: APP/webroot/css.
like image 913
Allen Liu Avatar asked Aug 09 '09 06:08

Allen Liu


2 Answers

If you want to make modifications to this controller it is recommended that you copy the default

cake/libs/controller/pages_controller.php to app/controller/pages_controller.php

The reason is because you should not modify anything inside the "cake" folder where any file can be overwriten when updating your application with the latest cakephp version.

like image 185
Héctor García Avatar answered Oct 14 '22 04:10

Héctor García


You can change the default behavior by changing the Route::connect() function arguments such as below:

Router::connect('/', array('controller' => 'requests', 'action' => 'index', 'home'));

and also if you want to connect all the actions to one action, use the code below in the same config file:

Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));

Of course you should change the arguments to your own needs.

This configuration is located under app/config/routes.php.

To get more information about Route::connect(), visit this page: http://api.cakephp.org/class/router#method-Routerconnect

like image 31
Tarik Avatar answered Oct 14 '22 04:10

Tarik