Typically you are supposed to use a plural form of the Model you are using for a controller (eg: UsersController
is for the User
model, which corresponds with the users
table). However, I want to add a controller that isn't really associated with any model or table, like a "Getting Started" set of pages.
I just wonder what the preferred way of handling something like this is for CakePHP.
If those are static pages, put them in views/pages/
and access them via /pages/xyz
. This uses the standard PagesController. If you want to make shorter routes instead of /pages/...
, create new routes in config/routes.php
(the default /
route shows an example).
If they are dynamic pages and need a real controller, name it whatever you want.
you can always do that. just make sure you set the $uses array correctly
var $uses = array();
if you dont need any model or
var $uses = array('MyModel');
if you want to use a particular model in this controller
精彩评论