Hello Everyone,
Can I ask a question ?
How can I create new CQ Page programmatically?
For example, I want to create new CQ page(menu1, menu2, menu3,…) in Menu folder programmatically.
Solved! Go to Solution.
Views
Replies
Total Likes
private void createPage(ResourceResolver resolver, String shipCode) throws Exception {
String path = "/content/test" ;
String pageName = "samplepage";
String pageTitle = "Sample page";
String template = "/apps/.../templates/test";
String renderer = "/apps/.../components/structure/test";
Page prodPage = null;
PageManager pageManager = resolver.adaptTo(PageManager.class);
prodPage = pageManager.create(path, pageName, template, pageTitle);
Node pageNode = prodPage.adaptTo(Node.class);
Node jcrNode = null;
if (prodPage.hasContent()) {
jcrNode = prodPage.getContentResource().adaptTo(Node.class);
} else {
jcrNode = pageNode.addNode("jcr:content", "cq:PageContent");
}
jcrNode.setProperty("sling:resourceType", renderer);
}
private void createPage(ResourceResolver resolver, String shipCode) throws Exception {
String path = "/content/test" ;
String pageName = "samplepage";
String pageTitle = "Sample page";
String template = "/apps/.../templates/test";
String renderer = "/apps/.../components/structure/test";
Page prodPage = null;
PageManager pageManager = resolver.adaptTo(PageManager.class);
prodPage = pageManager.create(path, pageName, template, pageTitle);
Node pageNode = prodPage.adaptTo(Node.class);
Node jcrNode = null;
if (prodPage.hasContent()) {
jcrNode = prodPage.getContentResource().adaptTo(Node.class);
} else {
jcrNode = pageNode.addNode("jcr:content", "cq:PageContent");
}
jcrNode.setProperty("sling:resourceType", renderer);
}
Hi,
We have a HELPX article on this topic.
See this: Adobe Experience Manager Help | Creating an Experience Manager 6.3 Page using the Page Manager API
Thanks,
Ratna
Views
Replies
Total Likes
Hi Ratna Kumar,
The link which you had mentioned is showing 404 error. Could you please help me with the correct link please
Thanks,
Pavan
Views
Replies
Total Likes
Thank you very much.
Views
Replies
Total Likes
Views
Likes
Replies