为了获得对Apache Sling的基本了解,我正在尝试使用它构建一个简单的博客应用程序。我定义了一个自己的节点类型 blog:post,用于单个帖子。
这是到目前为止内容存储库的结构:
/
|
|-content
| |
| |-blog
| |
| |-some-blogpost (jcr:primaryType=blog:post)
| |-another-blogpost (jcr:primaryType=blog:post)
|-apps
|
|-blog (jcr:primaryType=sling:Folder)
|
|-post
|
|-html.jsp
我可以通过打开 http://example.com/blog/some-blogpost.html 来引用特定的博客文章现在假设我想概述 http://example.com/blog 上提供的最新帖子。
我必须如何命名必要的脚本以及必须将其放在哪里?
亲切问候
马库斯
我不会为每个内容类型创建单独的JCR节点类型,而是使用sling:resourceType
属性。因此,您可以使用jcr:primaryType=nt:unstructured
创建新的博客文章,并向其添加属性sling:resourceType=blog/post
。
转到您的问题:您可以创建新的组件/apps/blog/recentPosts
(以及像/apps/blog/recentPosts/html.jsp
这样的脚本),然后在/content/blog
节点上设置sling:resourceType=blog/recentPosts
属性以告诉Sling应该使用哪个脚本来呈现此内容。