MainelyDesign.com Blog

Change View File from Controller in CakePHP 3

Posted on 01/27/2016 at 10:37 am by Kevin Wentworth
Viewed 8,433 times | 0 comments

You can change what view.ctp file you want to use in your controller with the following line of code.  I place it at the bottom of my function definition.  Useful for having a simple admin interface or a different view template for each language.  This doesn't change the layout of your page, just the view template the controller uses when rendering your content.

  1. $this->viewBuilder()->template('another_view');   // will use another_view.ctp instead of controller_name.ctp

Cheers,
-Kevin

Bookmark and Share

Tags for Change View File from Controller in CakePHP 3

Cakephp | Cake3 | Usage | Web Programming

Comments for this Posting

No comments. Be the first to post a reply.

Sorry, comments are closed for this posting.

Please Email Kevin if you have any questions. Thanks!

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design