Question

in order to gain a basic understanding of Apache Sling I'm trying to build a simple blogging application using it. I defined an own node type blog:post that is used for single posts.

This is the structure of the content repository so far:

/
|
|-content
|   |
|   |-blog 
|       |
|       |-some-blogpost (jcr:primaryType=blog:post)
|       |-another-blogpost (jcr:primaryType=blog:post)
|-apps
    |
    |-blog (jcr:primaryType=sling:Folder)
        |
        |-post
            |
            |-html.jsp

I can refer to a specific blog post by opening http://example.com/blog/some-blogpost.html Now suppose I wanted to have an overview of the most recent posts available at http://example.com/blog.

How do I have to name the necessary script and where do I have to put it?

Kind regards,

Markus

Was it helpful?

Solution

Rather than creating separate JCR node type for each content type, I'd use sling:resourceType property. So you could create new blog post with jcr:primaryType=nt:unstructured and add property sling:resourceType=blog/post to it.

Moving to your question: you could create new component /apps/blog/recentPosts (and script like /apps/blog/recentPosts/html.jsp) and then set sling:resourceType=blog/recentPosts property on the /content/blog node to tell Sling which script should be used to render this piece of content.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top