Interview Questions

What is the default extension of view files in cakephp?can we change it?if yes then how?

CakePHP Interview Questions and Answers


(Continued from previous question...)

What is the default extension of view files in cakephp?can we change it?if yes then how?

default extension of view files is '.ctp'.
yes we can change it by writing public $ext = '.yourext'; in AppController.If you want to change it for particular controller then add it into that controller only.You can also change it for the specific action of the controller by putting it in that action of controller.

public $ext = '.yourext'; in AppController
- you can change all the views extentions.
public $ext = '.yourext'; in specific controller like, PostsController
- you can change all the views extentions of PostsController.
public $ext = '.yourext'; in specific controller action like, index()
- you can change the view extention of index.ctp

Note: You cannot specify multiple extensions, however it seems like there is a fall back to .ctp if no .php file is found.

(Continued on next question...)

Other Interview Questions