Monday, 29 December 2014

Cakephp redirection

CakePHP Redirection



Redirecting:
$this->redirect(array('controller' => 'orders', 'action' => 'thanks'));
Redirecting to website:
$this->redirect('http://www.example.com');
Render the element for ajax:
$this->render('/Elements/ajaxreturn');
Redirect to 404 not found:
throw new NotFoundException('404 Error - Page not found');

If you need to redirect to the referer page you can use:
$this->redirect($this->referer());

If you need to redirect to the edit page with id:
$this->redirect(array(’action’ => ’edit’, $id));

Redirect to different action:
$this->render(’custom_file’);

Call element in controller action

$this->viewPath = 'Elements';
$this->render('sub_cat_list');      

0 comments:

Post a Comment