You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Ole Ersoy <ol...@gmail.com> on 2013/09/03 22:07:07 UTC

Default Content Work Flow

Hi,

I'm brand new to Sling and Jackrabbit.  I'd like to create a node with some default content on it.  Based on what I have read the way to do it is to create a new node type with the default content embedded in it.  For example I'd create a node type bar that lives in the namespace foo.  Then hopefully it's possible to do something like this:

curl -u admin:admin -F"sling:resourceType=foo/bar" -F"jcr:primaryType":"foo:bar" -F"title=some title" http://localhost:8080/content/mynode

So now mynode would be of type foo:bar and would contain the default content in the content property that I would have specified.  I could then render the content with a template like:

<html>
   <body>
     <div id="content"><%= currentNode.content %></div>
   </body>
</html>

Is this possible with Sling ATM?

Incidentally I'd like to have a simple way of defining new node types like foo:bar with custom content on them.  If this already exists, super!  If not I'd like to contribute if the community is interested.

TIA,
- Ole

Re: Default Content Work Flow

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Ole,

On Tue, Sep 3, 2013 at 10:07 PM, Ole Ersoy <ol...@gmail.com> wrote:
> ...hopefully it's possible to do something like this:
>
> curl -u admin:admin -F"sling:resourceType=foo/bar"
> -F"jcr:primaryType":"foo:bar" -F"title=some title"
> http://localhost:8080/content/mynode

Yes that would work, assuming you have registered the foo namespace
and bar nodetype before. This can be done with cnd files embedded in
bundles, see the jcr/resource bundle for example.

>
> So now mynode would be of type foo:bar and would contain the default content
> in the content property that I would have specified...

Default content specified in the node type? Yes that should work, and
this as well:

>     <div id="content"><%= currentNode.content %></div>

> ...Incidentally I'd like to have a simple way of defining new node types like
> foo:bar with custom content on them.  If this already exists, super!  If not
> I'd like to contribute if the community is interested....

So your only use of those node types is the default content? Not sure
if it's worth the effort of defining all those node types, and if it's
just static default content it can also be injected at rendering time.
For example by calling adaptTo to transform your content into
higher-level objects that provide the default content.

http://wiki.apache.org/jackrabbit/DavidsModel has a good explanation
of the general view on node types here - we usually use them as little
as possible.

-Bertrand