## 模板文件定義
每個模塊的模板文件是獨立的,為了對模板文件更加有效的管理,默認的模板文件定義規則是:
>[info]視圖目錄/操作名(小寫)+模板后綴
默認的視圖目錄是模塊的public\themes\目錄,框架的默認視圖文件后綴是`.php`
我們通過`main.layout.php`文件將系統所需要的公共js與css文件在此引用,內容如下:
~~~
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<title><?php echo $title; ?></title>
<link rel="stylesheet" href="<?php echo theme_url();?>/css/style.css">
<link rel="stylesheet" href="<?php echo theme_url();?>/css/iconfont/iconfont.css">
<link rel="stylesheet" href="<?php echo base_url();?>/misc/jquery-ui/jquery-ui.min.css">
<script type="text/javascript" src="<?php echo theme_url();?>/js/new.js"></script>
<script type="text/javascript" src="<?php echo theme_url();?>/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>/misc/jquery.form.js"></script>
<script type="text/javascript" src="<?php echo theme_url();?>/js/common.js"></script>
</head>
<body>
<?php echo $this->view['content']; ?>
<?php echo $this->view['end']; ?>
<?php $this->extend('alert_box'); ?>
</body>
</html>
~~~
當我們在頁面調用該公共文件是只需要如下操作即可實現,無需再次引用重復樣式與js:
~~~
<?php
$title = "啟動頁";
$this->layout('main');
?>
<?php $this->block('content');?>
<div class="bg bg-color">
<div class="index-content modular-table">
<div class="modular-cell">
<i class="icon"></i>
<h1 class="title">潮人美容美發</h1>
</div>
</div>
</div>
<?php $this->end(); ?>
<?php $this->block('end');?>
<meta http-equiv="refresh" content="3; url=<?php echo url('home/login/index');?>">
<?php $this->end(); ?>
~~~