On Dec 12, 2010, at 20:10, cricket wrote:
> You're using PagesController so, presumably, it's all the same action.
> Meaning, the same view, also (bydefault, I mean).
No... in fact it is my understanding that that's the exclusive purpose of the
pages controller: to provide a way to display a variety of different views
without the need to explicitly define an action for each in the controller. The
action for the pages controller is always "display" but the view changes based
on the first positional parameter. See the way routes are defined in a newly
created CakePHP 1.3.6 app in app/config/routes.php:
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/views/pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'pages', 'action' =>
'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' =>
'display'));
And the way the display method of the pages controller is defined in
cake/libs/controller/pages_controller.php
/**
* Displays a view
*
* @param mixed What page to display
* @access public
*/
function display() {
$path = func_get_args();
$count = count($path);
if (!$count) {
$this->redirect('/');
}
$page = $subpage = $title_for_layout = null;
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$title_for_layout = Inflector::humanize($path[$count -
1]);
}
$this->set(compact('page', 'subpage', 'title_for_layout'));
$this->render(implode('/', $path));
}
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en