## 模板文件定义
每个模块的模板文件是独立的,为了对模板文件更加有效的管理,默认的模板文件定义规则是:
>[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(); ?>
~~~