我是cakephp框架的新角色。我不能調用控制器的功能。 控制器 -如何使用默認函數在cakephp框架中調用控制器的函數?
class PagesController extends AppController {
public $name = 'Pages';
public $uses = array();
public function display() {
$path = func_get_args();
$count = count($path);
if (!$count) {
$this->redirect('/');
}
$page = $subpage = $title_for_layout = null;
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$title_for_layout = Inflector::humanize($path[$count - 1]);
}
$this->set(compact('page', 'subpage', 'title_for_layout'));
$this->render(implode('/', $path));
}
public function register() {
$this->set('fdf', 'chandan');
$this->render('home1');
}
}
但我調用顯示()。但我不是調用register()。我的routes.php文件喜歡 -
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
請幫幫我。如何從cakephp中查看調用控制器函數。 以及需要做些什麼設置?
也許你應該閱讀一些關於MVC設計模式的基礎知識 –
視圖不會調用控制器函數。調度員調用控制器,該控制器呈現我在codeigniter上工作的視圖 –
。我們可以在這裏寫作,如 cbnvbxcbvnbxcbv