Reputation: 103
I've been reading until my eyes are swollen, and having troubles finding what should be a simple answer.
I am not new to PHP, but I am new to cakePHP. Please bear with me, and have patience with my ignorance of lack of knowledge of the terminology.
I have been asked to help make some fixes on a cakePHP developed site, that was recently created.
The site is missing a page for "http://domain.com/logout". I can see the functions I need to access in the UserController, but I am not sure where to put the .ctp file to generate the view.
Let's just say I want the logout.ctl file to be something as simple as: echo "Hello World";
Under my app/View folder I have the sub-folders Home, & User that I have tried to place this file into. I am assuming I have to do something else as well, but I have not been able to locate what that is.
Any assistance is appreciated. Thanks for reading!
Upvotes: 0
Views: 459
Reputation: 610
1.By default, you should link your view and controller together by creating Views/Controller/action.ctp
.
Since the url is linked to Controller by routes, views are not associated with it directly.
For example, if you have set
Router::connect('/logout/', array('controller' => 'User', 'action' => 'logout'));
, then you may want to create Views/User/logout.ctp.
If you have set
Router::connect('/logout/', array('controller' => 'Home', 'action' => 'logout'));
, then you may want to create Views/Home/logout.ctp.
2.You can change the view in your action with $this->view='sample'
or $this->render('sample');
and then create the view file with name sample.ctp
.
3.You can also read a view of another folder with $this->render('/Sample/logout');
.
Reference: http://book.cakephp.org/2.0/en/controllers.html
4.If you use themes $this->theme = 'Example';
, the default view file will be set to /app/View/Themed/Example/Posts/edit.ctp
.
Reference: http://book.cakephp.org/2.0/en/views/themes.html
5.I think the default extension of cakephp view files is .ctp
but not .ctl
. .ctl
is used by Microsoft Visual Studio? I'm not quite sure.
Upvotes: 1