
在使用Phpcms时,为了提高开发效率和保持网站风格统一,通常会将头部(header)和尾部(footer)内容提取为公共模板文件,然后在其他页面中进行调用。这样修改一次就能全局生效,便于维护。
进入模板目录,一般路径为:/templates/default/模块名/(如content模块)。你可以创建两个独立的模板文件:
示例:在/templates/default/content/下新建 header.html 和 footer.html。
Phpcms 使用的是自定义模板语法,通过 {template '模块名','文件名'} 来包含模板。
立即学习“PHP免费学习笔记(深入)”;
在需要调用头部和尾部的模板文件中(如 show.html 或 list.html),插入以下代码:
{template 'content','header'}
{template 'content','footer'}说明:
以 list.html 为例:
```html {template 'content','header'}
https://www.php.cn/link/ac28746b6be492d540d42732395ed965'title']}
{/loop}{template 'content','footer'}
这样 header.html 和 footer.html 就会被自动嵌入到页面中。
4. 注意事项
基本上就这些,不复杂但容易忽略细节。只要文件存在、路径对、语法正确,就能顺利调用。