Свежайшие Пирожки от CakePHP по-русски

Полнейшее руководство CakePHP 1.2 на русском языке, горячие новости и полезные статьи

Routes

For some, CakePHP's default routing works well enough. Developers who are sensitive to user-friendliness and general search engine compatibility will appreciate the way that CakePHP's URLs map to specific actions. So we'll just make a quick change to routes in this tutorial.

For more information on advanced routing techniques, see "Routes Configuration".

By default, CakePHP responds to a request for the root of your site (i.e. http://www.example.com) using its PagesController, rendering a view called "home". Instead, we'll replace this with our PostsController by creating a routing rule.

Cake's routing is found in /app/config/routes.php. You'll want to comment out or remove the line that defines the default root route. It looks like this:

Простой текст
  1. Router::connect ('/', array('controller'=>'pages', 'action'=>'display', 'home'));

This line connects the URL '/' with the default CakePHP home page. We want it to connect with our own controller, so add a line that looks like this:

Простой текст
  1. Router::connect ('/', array('controller'=>'posts', 'action'=>'index'));

This should connect users requesting '/' to the index() action of our soon-to-be-created PostsController.