## 模板制作

可自由制作 **花里胡哨** 的CMS前台主题模板 。

### 制作流程

1. 添加主题：CMS » CMS配置 » 网站主题 » 编辑 » 选项设置 加入：demo=测试模板(标识=名称，自定义)。
2. 切换主题：选择新主题并保存配置，也可url中添加 ?t=标识 进行切换。
3. 把所需静态资源文件(css,js,img)放入 public/static/themes/demo 目录下。
4. 在模板 tempalte 目录下建立 demo/index 目录。
5. 建立 index.html 首页模板开始制作。

### 模板文件

```
index.html				// 首页模板
_header.html			// 公共头部
_footer.html			// 公共底部
_sidebar.html			// 文章边栏
404.html				// 404页面
about.html				// 单页模板
news.html				// 文章列表
news_detail.html		// 文章详情
product.html			// 产品列表
product_detail.html		// 产品详情
message.html			// 留言页面
service.html			// 服务页面
```

### 通用标签

```
模板包含：{include file='index/_header.html'}
资源路径：__STATIC__/themes/__THEME__
根目录：__ROOT__
echo配置：{:site('配置名', '默认值')}
配置转数组：{php $cate=site('site_cate','分类1|分类2', true)}
生成URL：{:url('news/detail?id=1')}
获取10条数据：
{php $last=db('news')-&gt;field('id,title,update_time')-&gt;where('status=1')-&gt;order('id DESC')-&gt;limit(10)-&gt;cache(30)-&gt;select()}
偱环输出：
{foreach $last as $vo}
    ID: {$vo.id}
    标题截取：{$vo.title|str_substr=10}
    格式时间：{$vo.update_time|date='Y-m-d'}
{/foreach}
```

>本文档由 [APHP文档系统](https://doc.aphp.top) 生成，文档更新于：2024-10-25 16:00:57