March 22, 2021
Estimated Post Reading Time ~

How to Create/Delete CQ5/AEM page through Javascript

We can create / delete the CQ page by using OOTB service /bin/wcmcommand by passing necessary parameters.

1) Create : To create page do POST Ajax call to /bin/wcmcommand with below parameters object

var data = {};
var title = Title of Page //required
var label = name of the page //optional
data['cmd'] = "createPage";
data['title'] = title;
data['_charset_'] = "utf-8";
data[':status'] = "browser";
data['template'] = template path // like -- /apps/geometrixx/templates/homepage
data['parentPath'] = parent page path // like -- /content/geometrixx/en

$.ajax({
type : "POST",
url : '/bin/wcmcommand',
data:data,
}).done(function(data) {console.log(data);});

2) Delete : To delete page do POST Ajax call to /bin/wcmcommand with below parameters object

var data = {};
data['cmd'] = "deletePage";
data['_charset_'] = "utf-8";
data['force'] = false;
data['path'] = page apth;// like -- /content/geometrixx/en/test

$.ajax({
type : "POST",
url : '/bin/wcmcommand',
data:data
}).done(function(data) {console.log(data);});



By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.