How to implement a default view in CakePHP? -
in cakephp each method of controller has own view , view template file name of method.
class datacontroller extends appcontroller { public function one() { // render one.ctp } public function two() { // render two.ctp } }
accourding api documentation there $view
property of controller specifies view render. should have ability specify default view file, all.ctp
, methods of controller
class datacontroller extends appcontroller { public $view = 'all'; public function one() { // should render all.ctp } public function two() { // should render all.ctp } }
however not work , cakephp ignores $view
property , continues template file of same name method.
is there way have default view without having insert $this->render('all');
in each of controller's methods?
the value going overridden in controller::setrequest()
being called in controllers class constructor.
you use controllers beforefilter()
callback instead set value:
public function beforefilter() { parent::beforefilter(); $this->view = 'all'; }
Comments
Post a Comment