创建一个模板–kohana3使用手册
第一步,当用 Kohana创建一个基于模板的网站时,当然就是创建模板。
默认情况下,Kohana假定模板文件叫做 *template.php*,并且位于 views 文件夹
/home/kerkness/kohana/application/views/demo/template.php
你的模板文件要包含完整的你网站的 headers 和 footers 并且 echo 那些在你的控制器中要被插入的包含动态内容的变量。下面是一个包含动态内容的非常基本的模板
■ title(string) – 这是页面的 title
■ scripte(array) – 这是页面中需要导入的 Javascript 脚本组成的数组
■ styles(array) – 这是模板中需要导入的 CSS 样式表组成的数组
■ content(string) – 这是页面的内容
<html xmlns=”http://www.w3.org/1999/xhtml” dir=”ltr” lang=”en-US”>
<head profile=”http://gmpg.org/xfn/11″>
<title><?php echo $title ?></title>
<meta http-equiv=”content-type” content=”text/html; charset=UTF-8″ />
<?php foreach ($styles as $file => $type) echo HTML::style($file, array(‘media’ => $type)), “\n” ?>
<?php foreach ($scripts as $file) echo HTML::script($file), “\n” ?>
</head>
<body>
<?php echo $content ?>
</body>
</html>
你的模板可以是非常复杂或者非常简单,只要你喜欢,可以根据你的需要添加许多动态元素