Silverstripe 不使用 HomePage.ss 作为 Chrome?
Silverstripe not using HomePage.ss as Chrome?
您好,我学习了 Silverstripe 课程 https://www.silverstripe.org/learn/lessons/v4/working-with-multiple-templates-1,甚至尝试从存储库下载代码,但是当我尝试创建 templates/HomePage.ss 时 chrome Silverstripe 仍然使用 Page.ss。很明显课程说 "It first looks in the main templates/ directory to find the chrome for this page. If it finds HomePage.ss in there, it will select that as your chrome." 缺少什么?
Silverstripe 有问题,我遇到了同样的问题。只需切换到 Wordpress。
您需要在模板文件夹中创建几个文件夹,如该课所述:
Make a directory called templates/SilverStripe/Lessons. In that directory, create another directory called Layout/. In that directory, create HomePage.ss. The full path should be templates/SilverStripe/Lessons/Layout/HomePage.ss.
所以您基本上需要将文件从 templates/HomePage.ss 移动到 templates/SilverStripe/Lessons/Layout/HomePage.ss
这里的问题是您混淆了 Page
模板和 HomePage
模板之间的想法。
Page
'chrome' 模板(如本课所称)位于 templates/
中,因为 Page
class 是 而非 命名空间,或者它驻留在 root 命名空间中。
另一方面,HomePage
class 是 命名空间,这必须反映在模板的路径中。
- 一个
main
模板('chrome'),模板应该在templates/SilverStripe/Lessons/
Layout
模板应位于同一库中,但带有 Layout 文件夹; templates/SilverStripe/Lessons/Layout
此信息在课程中。
我知道您很沮丧,但是在找到您的问题的答案之前传播恐惧不确定性和对错误的怀疑并不是一件好事。
您好,我学习了 Silverstripe 课程 https://www.silverstripe.org/learn/lessons/v4/working-with-multiple-templates-1,甚至尝试从存储库下载代码,但是当我尝试创建 templates/HomePage.ss 时 chrome Silverstripe 仍然使用 Page.ss。很明显课程说 "It first looks in the main templates/ directory to find the chrome for this page. If it finds HomePage.ss in there, it will select that as your chrome." 缺少什么?
Silverstripe 有问题,我遇到了同样的问题。只需切换到 Wordpress。
您需要在模板文件夹中创建几个文件夹,如该课所述:
Make a directory called templates/SilverStripe/Lessons. In that directory, create another directory called Layout/. In that directory, create HomePage.ss. The full path should be templates/SilverStripe/Lessons/Layout/HomePage.ss.
所以您基本上需要将文件从 templates/HomePage.ss 移动到 templates/SilverStripe/Lessons/Layout/HomePage.ss
这里的问题是您混淆了 Page
模板和 HomePage
模板之间的想法。
Page
'chrome' 模板(如本课所称)位于 templates/
中,因为 Page
class 是 而非 命名空间,或者它驻留在 root 命名空间中。
另一方面,HomePage
class 是 命名空间,这必须反映在模板的路径中。
- 一个
main
模板('chrome'),模板应该在templates/SilverStripe/Lessons/
Layout
模板应位于同一库中,但带有 Layout 文件夹;templates/SilverStripe/Lessons/Layout
此信息在课程中。
我知道您很沮丧,但是在找到您的问题的答案之前传播恐惧不确定性和对错误的怀疑并不是一件好事。