摘要:文件包含:demo5.html:{include file = "public/title.html" assign = "title" brand = "华帝"}//include file = "public/title.html"这句是将title.html这个文件包含进来,即将title.html文件内容引用到
文件包含:
demo5.html:
{include file = "public/title.html" assign = "title" brand = "华帝"}//include file = "public/title.html"这句是将title.html这个文件包含进来,即将title.html文件内容引用到demo5.html文件中,assign = "title"是将引用进来的内容存到title变量中,brand = "华帝"是将变量brand的内容传给title.html中。
{$title}
title.html:
中消协向{$brand}发出约谈函
模板继承:
layout.html://父模板
...
{block name = "title"}页面标题{/block}//block标签之间的为父模板的区块...
demo6.html//模板文件
{extends file = "layout.html"}//有点类似类,模板文件继承父模板,包含文件是include,继承是extends
{block name = "title"}//实例化父模板中的区块
... //内容自己填写
{$smarty.block.parent}//也可以直接继承父模板的内容
{/block}
批改老师:欧阳批改时间:2019-01-19 13:48:06
老师总结:完成的不错,模版要多练习,学php最终目的,就是会模版,可以上手项目,加油。