Reputation: 739
When i enter address: http://www.yourdomain.com/2 (without page:2)
It give you Missing View: (error)
Missing View
Error: The view for PagesController::display() was not found.
Error: Confirm you have created the file: /Users/username/Sites/mycakeapp/views/pages/2.ctp
Notice: If you want to customize this error message, create /views/errors/missing_view.ctp
In router config: (routes.php in config)
$chk = array('page' => '[0-9]');
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::connect('/:page/*', array('controller' => 'pages', 'action' => 'display'), array(
'page' => $chk['page'], 'pass' => array('page')
));
In pages_controller.php:
function display($on_page=1) {
$this->paginate = array(
'limit' => $this->Cookie->read('pagelimit'),
'page' => $on_page,
'order' => array(
'data.dateadded' => 'asc'
));
$data = $this->paginate('data');
$this->set('data', $data);
$this->render(implode('/', $path));
$this->set('title_for_layout', null);
}
Upvotes: 0
Views: 836
Reputation: 739
I found problem solved. the answer is:
add in controller page:
$this->render('/pages/home');
no need to add Router::connectNamed
Upvotes: 0
Reputation: 2432
Like the error message states, you need to have a file called 2.ctp in your pages folder.
Confirm you have created the file: /Users/username/Sites/mycakeapp/views/pages/2.ctp
The display method in the pages_controller is generally used to display static pages. A file named with the param you send, in your case 2, followed by '.ctp' must exist in the view/pages folder, this is what the error message tells you.
If you where expecting something else, you are not doing it right.
Upvotes: 0
Reputation: 6360
Try adding all named parameters to the routes config manually:
Router::connectNamed(array('page'[, ...]);
Upvotes: 1