【发布时间】:2019-12-09 23:15:07
【问题描述】:
我正在使用 Beego,并且能够在 index.tpl 页面(具有网站横幅、菜单导航、页脚等)上使用持久模板但是,当我单击索引页面并转到我的静态页面之一,即“联系”页面。永久模板不会出现。如何将持久模板添加到 /static/pages 目录下的所有静态页面。
【问题讨论】:
标签: templates persistent beego
我正在使用 Beego,并且能够在 index.tpl 页面(具有网站横幅、菜单导航、页脚等)上使用持久模板但是,当我单击索引页面并转到我的静态页面之一,即“联系”页面。永久模板不会出现。如何将持久模板添加到 /static/pages 目录下的所有静态页面。
【问题讨论】:
标签: templates persistent beego
您应该使用布局概念。
用于主页控制器;
this.Layout = "layout.html"
this.TplNames = "index.html"
用于联系页面控制器;
this.Layout = "layout.html"
this.TplNames = "contact.html"
layout.html
{{template "header.html"}}
{{template "banner.html"}}
{{.LayoutContent}}
{{template "footer.html"}}
LayoutContent 变量引用控制器 TplNames 文件。
【讨论】: