This my link in newsses/index.ctp
$this->Html->link(__("Read more >>", TRUE), array('action'=>'view', $newss['Newsse']['title']));
and this my view code in newsses_controller.php:
function view($title = NULL){
$this->set('title_for_layout', __('News & Event', true));
if (!$id) {
$this->Session->setFlash(__('Invalid News.', true), 'default', array('class' => 'error'));
$this->redirect(array('action'=>'index'));
}
$this->set('newsse', $this->Newsse->read(NULL,$title));
$this->set('newsses', $this->Newsse->find('all'));
}
but it does’t showing anything,
i want to make route like:
“newsses/view/2” to “newsses/view/title_of_news”
please help me….
You’re using the
Model::read()method method which takes as the second argument theidof the row in your Model’s table that you want to access. It’s better to use find in this case. You don’t need to build a new method in your model or your controller, you can just edit the currentviewmethod.Or, you can make a more hybrid form in which viewing by id is still possible when a numerical title is given (this assumes you never have news items which have a title consisting of only numeric characters, e.g. ‘12345’).
Finally, you can also replace the
findmethod in my example with a (shorter) customfindBymethod (see the documentation for more info about this).