layout模版布局
存放位置
主题下面,如“default主题下面有个default layer”
/template/default/default.layer.php
怎样加载共用模版
比如要加载共用的头部,我们可以直接在模版里面这样写,这样就载入了当前主题下面Public/header.tpl.php如:/template/default/Public/header.tpl.php
<?php $this->_loadFile('Public/header.tpl.php') ?>
原理
<?= $this->_loadContent(); ?>
给出一个layout模版例子
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="keywords" content="<?= $this->metaKeywords(); ?>" />
<meta name="description" content="<?= $this->metaDesc(); ?>" />
<link rel="stylesheet" href="<?= $this->staticRes('css/base.css'); ?>">
<link rel="stylesheet" href="<?= $this->staticRes('css/common.css?v=1.0.2'); ?>">
<link rel="stylesheet" href="<?= $this->currentCss(); ?>">
<title><?= $this->title ?> - TimoPHP</title>
</head>
<body>
<header class="header">
<div class="wrap">
<div class="con">
<a class="logo fl" href="/"><img src="<?= $this->res('images/logo.png'); ?>" /></a>
<ul class="nav fl">
<?php foreach($this->data['nav'] as $item): ?>
<li><a href="<?= $this->link($item['url']) ?>"<?= $this->data['current_nav'] == $item['url'] ? ' class="on"' : '' ?>><?= $item['name'] ?></a></li>
<?php endforeach; ?>
</ul>
<a class="avatar fr" href="<?= $this->link('member'); ?>"><img src="<?= $this->res('images/avatar.jpg'); ?>" /></a>
</div>
</div>
</header>
<?= $this->_loadContent(); ?>
<footer class="footer">
<p>
<a href="">关于我们</a> |
<a href="">联系我们</a> |
<a href="">用户条款</a> |
<a href="">隐私申明</a> |
<a href="">加入我们</a>
</p>
<p class="fs12">Powered by <a target="_blank" title="开源社区" href="http://www.timophp.com/">TimoPHP</a> 1.2 Copyright © 2016 - 2020 <a target="_blank" href="http://www.timophp.com/">TimoPHP</a> 蜀ICP备08335298号</p>
</footer>
</body>
</html>