Coding Cheatsheets - Learn web development code and tutorials for Software developers which will helps you in project. Get help on JavaScript, PHP, XML, and more.

Post Page Advertisement [Top]

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');      

No comments:

Post a Comment

Bottom Ad [Post Page]