Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Display nodes under a component

Avatar

Level 1

Hi,

I would like to do ask how can I display nodes that are copied over like parsys does.

String nodePath = properties.get("./nodePath",String.class); String nodeWidth = properties.get("./nodeWidth",String.class); String nodeHeight = properties.get("./nodeHeight",String.class); if(nodePath!= null){ //get referring node resources Resource r = resourceResolver.getResource(nodePath); Node referringNode = r.adaptTo(Node.class); String[] temp = nodePath.split("/"); String referringName = temp[temp.length-1]; Node contentNode = currentNode.addNode("content"); contentNode.setPrimaryType("cq:PageContent"); contentNode.setProperty("sling:resourceSuperType", "foundation/components/page"); JcrUtil.copy(referringNode, contentNode, referringName); contentNode.getSession().save(); currentNode.getSession().save(); } else{ %><p>Right-click to make changes. Settings cannot be changed. If needed changes, then delete and add component again</p><%     }

Basically, my component shows a dialog which allows me to select a node which will be copied over to a specific page. The problem is it only shows when the copied node is placed under par (parsys) and does not show when it is under my component. This is because I need the dialog box to surround the child nodes. I have tried using another parsys and as above I am using page component, but the ticker tape (image below) is not showing. Is there anyway to do this? Or will I just have to stick with using parsys as the parent component?

[img]Screen Shot 2015-09-23 at 5.58.55 pm.png[/img]

1 Accepted Solution

Avatar

Correct answer by
Level 10

you need a container for you component to be rendered right ? so you need to place it under par. If you dont want that to be under parsys, then you need to include that component with the template you are using to create the page programmatically. Then it can be created directly under the page without par.

View solution in original post

2 Replies

Avatar

Level 10

For this use case - placing nodes under other nodes (copying nodes) all depends on the node hierarchy. Some nodes cannot be children of other nodes. To be on the safe side - use parsys as the parent component.

Avatar

Correct answer by
Level 10

you need a container for you component to be rendered right ? so you need to place it under par. If you dont want that to be under parsys, then you need to include that component with the template you are using to create the page programmatically. Then it can be created directly under the page without par.