【问题标题】:Apache Sling index page/directory listingApache Sling 索引页面/目录列表
【发布时间】:2014-01-02 15:02:59
【问题描述】:

为了获得对 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 上的最新帖子。

我如何命名必要的脚本,我必须把它放在哪里?

亲切的问候,

马库斯

【问题讨论】:

    标签: aem sling


    【解决方案1】:

    我不会为每种内容类型创建单独的 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 应该使用哪个脚本来呈现这段内容。

    【讨论】:

    • 非常感谢!这行得通,事后看来似乎合乎逻辑。我想这需要一些时间来适应 Sling 以内容为中心的特性。
    猜你喜欢
    • 2020-05-16
    • 2014-09-29
    • 1970-01-01
    • 1970-01-01
    • 2015-02-25
    • 2014-04-20
    • 1970-01-01
    • 2016-08-04
    相关资源
    最近更新 更多