-1

I am new to CQ ,How to create new custom Node type in Day(adobe) CQ5.4 like mycmpny:testNode

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
CQ user
  • 11
  • 1
  • 2

2 Answers2

3

You can get a NodeTypeManager from the workspace like so:

NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
manager.registerNodeTypes(myNewNodeType, true);

There is some additional information on custom node types and administration on the day site.

However, you may be best avoiding schemas to start with and perhaps adding later if necessary. See Michael Marth's Structured or unstructured? In JCR you do not have to choose for another way at looking at this. This is something echoed by JCR spec lead David Nuescheler.

diffa
  • 2,986
  • 1
  • 22
  • 35
  • Thank you very much ,Can I use import node option in Node Adminstration .How to use this custom type node in component – CQ user Jan 28 '13 at 17:28
  • 2
    Through the CRX explorer, you can go into Node Type Administration select the Import Node Types menu item. From there you can enter the node definition in CND Format. [CND in a nutshell](http://jtoee.com/jsr-170/compact-node-type-notation-in-a-nutshell/) describes the format. – diffa Jan 29 '13 at 09:57
1

If you look at what node types can do for you, there are basically three things:

  1. give names to things - but you can also use conventions like Sling's resource type for this
  2. prevent certain content from being stored - but the rules will change over time
  3. provide for efficient observation

The third point is probably the most important reason to introduce custom node types at all. If you do not want to observe all changes in a certain part of the repository, then node types provide for an efficient filter. (This was captured from a post by Lars Trieloff, Product Manager Adobe CQ5)

Those are pretty much the only reasons to use a custom node type.. I have only used custom node types in a few scenarios and most times it has to do with indexing and complex jcr queries. From the sound of your question, it sounds like you are doing neither of these. I would suggest using the out of box node types.

To create a new node type create a folder called nodetypes and place a example.cnd file in there that contains something of the following

<'example'='http://www.somedomain.com/example'>

[example:Audit]   
   - * (undefined)

It should also have a .content.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    xmlns:rep="internal" jcr:mixinTypes="[rep:AccessControllable]"
    jcr:primaryType="nt:folder" />
Steven Gall
  • 113
  • 7