如何在不调用默认 Page.ss 模板的 silverstripe 中创建页面
How to create a page in silverstripe that does not call the default Page.ss template
我需要为主页制作一个 "under construction" 页面。
我创建的所有模板都使用默认 Page.ss 来构建 head/nav 和页脚。但在构建页面中我不想那样做。
如何在我的新页面类型中省略 Page.ss 的使用?
这是我的Page.ss,用作创建每个页面类型的基础
<!doctype html>
<html lang="en">
<head>
<% base_tag %>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
$MetaTags
</head>
<body>
<% include GraphicHeader %>
<% include HeadNav %>
$Layout
<% include Footer %>
</body>
您可以使用像 this one 这样的维护模式模块,然后将页面修改为 "under construction"。
这将允许您在网站上工作,同时让 public 查看 "under construction",直到您准备好打开它。
您的主题中有两个名为 Page.ss 的文件。
- /themes/yourtheme/templates/Page.ss 用于您网站的外部结构(
<head>
和 <body>
)
- /themes/yourtheme/templates/Layout/Page.ss 通过
$Layout
变量包含并定义每个页面类型的内部结构。
您的 Page_Controller
会自动尝试使用名为相关页面 class(例如主页)的模板来呈现自身,并搜索布局和基本模板。如果找不到,它会回退到名为父 class 等的模板,直到找到您的 Page.ss
。
这对外部和内部布局的模板都有效。
因此,如果您的主页 class 名为 HomePage
,只需将 HomePage.ss 放入 /themes/yourtheme/templates/ 它被 HomePage
及其子 class 占据。
使用维护模块(参见 Robbie Averill 的回答)可能是您的情况下更可靠的解决方案。
我需要为主页制作一个 "under construction" 页面。
我创建的所有模板都使用默认 Page.ss 来构建 head/nav 和页脚。但在构建页面中我不想那样做。
如何在我的新页面类型中省略 Page.ss 的使用?
这是我的Page.ss,用作创建每个页面类型的基础
<!doctype html>
<html lang="en">
<head>
<% base_tag %>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
$MetaTags
</head>
<body>
<% include GraphicHeader %>
<% include HeadNav %>
$Layout
<% include Footer %>
</body>
您可以使用像 this one 这样的维护模式模块,然后将页面修改为 "under construction"。
这将允许您在网站上工作,同时让 public 查看 "under construction",直到您准备好打开它。
您的主题中有两个名为 Page.ss 的文件。
- /themes/yourtheme/templates/Page.ss 用于您网站的外部结构(
<head>
和<body>
) - /themes/yourtheme/templates/Layout/Page.ss 通过
$Layout
变量包含并定义每个页面类型的内部结构。
您的 Page_Controller
会自动尝试使用名为相关页面 class(例如主页)的模板来呈现自身,并搜索布局和基本模板。如果找不到,它会回退到名为父 class 等的模板,直到找到您的 Page.ss
。
这对外部和内部布局的模板都有效。
因此,如果您的主页 class 名为 HomePage
,只需将 HomePage.ss 放入 /themes/yourtheme/templates/ 它被 HomePage
及其子 class 占据。
使用维护模块(参见 Robbie Averill 的回答)可能是您的情况下更可靠的解决方案。