参考にさせて頂いたページ
ビューを使おう!(1/3):初心者のためのCakePHP2.0 プログラミング入門
まず準備
まずapp/View
の中にSample/index.ctp
を作成する。
これはapp/View/コントローラ名/アクション名.ctp
index.ctpの記述内容
参考サイトにならって
<html>
<head>
<titile>Index Page</titile>
</head>
<body>
<h1>Index Page</h1>
<p>this is test View.</p>
</body>
</html>
SampleController.phpの記述内容
<?php
App::uses('AppController', 'Controller');
class SampleController extends AppController {
public function index() {
$this->autoLayout = false;
}
}
ページを確認する
http://192.168.33.10/cakephp/sample/index
にアクセスすると、app/View/Sample/index.ctp
の内容が表示される。
今回のまとめ
app/View
ディレクトリの中にコントローラー名と同じディレクトリを作成する。
そのディレクトリの中に、アクション名と同じctpファイルを作成する。
app/View/コントローラ名/アクション名.ctp
となる。