【发布时间】:2018-10-04 14:21:04
【问题描述】:
我是 Hippo CMS 的新手,并且已经完成了教程。一切都很顺利。但是,我有几个问题,希望得到答案。
1) 我需要为我创建的每个文档创建一个新控制器吗?或者我可以简单地为一个控制器中的每个文档重复以下代码行:
Simpledocument document = (Simpledocument) ctx.getContentBean();
if (document != null) {
// Put the document on the request
request.setAttribute("document", document);
}
对我来说,我必须为每个文档创建一个新控制器,这完全没有意义。这可能会变得一团糟。
2) 在 Hippo CMS 控制台中创建动态 hello world 文档的步骤。我是否必须对每份文件都执行所有这些步骤?我有一种感觉……
public class SimpleComponent extends BaseHstComponent {
public static final Logger log = LoggerFactory.getLogger(SimpleComponent.class);
@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) throws HstComponentException {
super.doBeforeRender(request, response);
final HstRequestContext ctx = request.getRequestContext();
// Retrieve the document based on the URL
HelloWorldTut document = (HelloWorldTut) ctx.getContentBean();
HelloWorldList docList = (HelloWorldList) ctx.getContentBean();
if (document != null) {
//Put the document on the request
request.setAttribute("doc", document);
request.setAttribute("docList", docList);
}
}
}
当然,HelloWorldTut 和 HelloWorldList 是两种不同的文档类型。
【问题讨论】:
-
不确定否决票。但是,这是该教程的链接。 onehippo.org/trails/deep-dive/hello-world.html