在 Magnolia cms 中的模板脚本中包含页面
如何将 Magnolia 的页面包含到 Magnolia 模板脚本中?
在模板脚本中,我可以访问特定页面的数据,但如何将该页面加载到模板中?
假设我有 2 个页面,每个页面都有自己的模板。第 1 页包含在其树中第 2 页。我想包含在第 1 页、第 2 页的模板脚本中,但不起作用。
非常感谢:)
更新
我真正想做的是将我的标题包含在我的项目的所有页面中。但我不想把它作为一个段落,因为如果我想更改标题,我将不得不编辑项目的所有页面。
因此,我尝试做的(但我不知道这是否是正确的方法)是为标题创建页面模板。该模板不会包含任何 , 或 css ,它只是标题的代码。 我想做的下一件事是在 Magnolia 中创建一个页面,并以该模型作为标题。 接下来,我想将刚刚创建的页面包含在项目的主模板模型中,但我不知道如何做到这一点。
我是 Magnolia cms 的新手,最初我尝试使用 stk 创建演示网站。唯一的问题是我无法使用jsp作为脚本语言,或者至少我在互联网上找不到任何解决方案。我不太了解 freemarker,但这并不是一个大问题。我真的很不愿意使用freemarker,因为也许将来在一个更复杂的项目中我可能需要一些freemarker不支持的功能,但jsp支持。如果可以的话,我想使用 jsp 构建我的网站。
我对这么长的更新感到抱歉,但是如果有人对最佳实践有任何建议,并且如果我可以在 jsp 中实现我想要的内容,我将非常感激。
再次感谢您抽出时间:)
How can I include a page from magnolia into a magnolia template script?
In the template script with I can access data from a specific page, but how can I load that page into the template?
Let's say I have 2 pages each with its own template. Page 1 contains in its tree page 2. I want to include in the template script of page 1, page 2, but doesn't work.
Thank you very much :)
UPDATED
What I actually want to do is include my header in all of my project's pages. But I don't want to put it as a paragraph, because if I ever want to change my header, I'll have to edit all the project's pages.
So what I try to do and I don't know if this is the correct approach is to create a page template for the header. This template won't include any , or css, it's just the code for the header.
The next thing I want to do is create a page in magnolia with that model to be the header.
Next I'd like to include the page I've just created in my main template model for the project, but I can't figure how to do that.
I am new to Magnolia cms and initially I tried creating my demo site using stk. The only problem was that I couldn't use jsp as a scripting language, or at least I couldn't find any solution on the internet. I don't really know freemarker, but that's not really a big problem. I'm really reluctant in using freemarker because maybe in the future in a more complex project I might need some features that freemarker doesn't support, but jsp does. I'd like to build my site using jsp if that's possible with magnolia.
I'm sorry for this long update, but if anyone has any suggestions on what a best practice could be and if I could implement what I want in jsp I would be really grateful.
Thanks again for you time :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用 STK,请参阅内容重用。
如果没有,请查看 cms tag-lib,尤其是 cms:loadPage 和 cms:setNode 标签,您可以使用它们获取一段内容并将其设置为 JSP/JSTL 变量然后使用 cms:includeTemplate 渲染它。
一个常见的场景是从父页面“继承”内容,标题就是一个很好的例子。您所做的就是对于一个区域,您沿着内容层次结构向上移动,并以相同的名称呈现其区域中父页面中的所有内容。这样,您仅添加到顶部页面的标题将包含在其所有子页面中。
另一种选择是有一个特殊的页面,它只保存要包含在其他页面中的内容。像页眉、页脚和横幅一样,应该放在某些页面的侧窗格中。
If you're using the STK then see this guide on content-reuse.
If not have a look at the cms tag-lib, especially the tags cms:loadPage and cms:setNode with which you can get a piece of content and set it as a JSP/JSTL variable and then render it using cms:includeTemplate.
A common scenario is to 'inherit' content from the parent page, the header is an excellent example of this. What you do is for an area you walk up the content hierarchy and render everything from the parent pages in their area with the same name. This way the header which you've only added to the top page is included in all its children.
Another option is to a have special page which simply holds things to be included in other pages. Like header, footer and banners that should go in the side pane of some pages.
将一个页面包含在另一个页面中实际上并不起作用。第 2 页已经有自己的 了标签,它自己的
不过,您有几个选择:
希望能有所帮助!
Including a page within another page doesn't really work. Page 2 already has its own <html> tags, its own <script> tags, and its own CSS, so including it wholesale into another page just simply doesn't make sense.
You do, however, have a couple of options:
Hope that helps a bit!