Created
April 21, 2014 14:25
-
-
Save Khanashima/11144257 to your computer and use it in GitHub Desktop.
viewの共通テンプレートを作成する ref: http://qiita.com/kiimiiis/items/a015399455ef9c0f1659
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Controller_Base extends Controller_Template | |
{ | |
public function before() | |
{ | |
parent::before(); | |
//header.phpをテンプレートの$headerとbindさせる。 | |
$this->template->header = View::forge('parts/header'); | |
//footer.phpをテンプレートの$footerとbindさせる。 | |
$this->template->footer = View::forge('parts/footer'); | |
} | |
public function after($response) | |
{ | |
$response = parent::after($response); // あなた自身のレスポンスオブジェクトを作成する場合は必要ありません。 | |
return $response; // after() は確実に Response オブジェクトを返すように | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Controller_Hello extends Controller_Base | |
{ | |
public function action_index() | |
{ | |
//template.phpのcontentとアクション毎のviewをbindさせる | |
$this->template->content = View::forge('hello/index'); | |
//デフォルト設定を変えず、template.phpのファイル名を変更しない場合はtemplateのviewオブジェクトを返す | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
コンテンツ領域です | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<?php echo HEADER; ?> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
</head> | |
<body> | |
<header> | |
<!-- header.phpファイルを読み込む--> | |
<?php echo $header; ?> | |
</header> | |
<div id="content"> | |
<!-- 各アクションの内容を読み込む--> | |
<?php echo $content; ?> | |
</div> | |
<footer> | |
<!-- footer.phpファイルを読み込む--> | |
<?php echo $footer; ?> | |
</footer> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
</head> | |
<body> | |
<header> | |
<!-- header.phpファイルを読み込む--> | |
<div> | |
ここはheaderの領域です | |
</div> | |
</header> | |
<div id="content"> | |
<!-- 各アクションの内容を読み込む--> | |
<div> | |
コンテンツ領域です | |
</div> | |
</div> | |
<footer> | |
<!-- footer.phpファイルを読み込む--> | |
<div> | |
ここはfooterの領域です | |
</div> | |
</footer> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment