To customize OOTB create page wizard you should perform following step(s) depending on the type of customization you are looking for-
1. Customize the template fields shown in wizard step-2
First, you need to override the cq:dialog of page component to configure what fields should be shown in create page wizard. In this dialog set the following property to true which you want to display in page create wizard-
true
|
2. Customize the template selection step in wizard step-1
You need to write a clientlib file with following code to handle the template selection step-
This example explains how to auto select the template if only one template is available for selection-
$(document).on("foundation-contentloaded", function(e) {
if (($(".foundation-collection-item").length==1) && ($(".foundation-collection-item.selected").length == 0)) {
$('.foundation-collection-item').click();
$(':button.coral-Wizard-nextButton').click();
}
});
Category of the clientlibs can be any of this depending on your requirement-
app.myproject.createpagewizard, cq.gui.siteadmin.admin.publishwizard, dam.gui.admin.publishassetwizard
In order to attach this new clientlibs to create page wizard, you need to overlay the wizard's head component and add your custom category i.e. "app.myproject.createpagewizard" as shown in below diagram-
3. Customize the confirmation Step-3
Once you have submitted the create page form, there comes a popup window for confirmation, if you want to modify the form submit behavior then you can do following customization-
(function(window, document, Granite, $) {
"use strict";
var ui = $(window).adaptTo("foundation-ui");
function createPage(wizard) {
$.ajax({
type: wizard.prop("method"),
url: wizard.prop("action"),
contentType: wizard.prop("enctype"),
data: wizard.serialize()
}).done(function(html) {
var $html = $(html);
var edit = $html.find("a.cq-siteadmin-admin-createpage-edit");
window.location = edit.prop("href");
}).fail(function(xhr, error, errorThrown) {
if (error === "error") {
var $html = $(xhr.responseText);
if ($html.find(".foundation-form-response-status-code").length > 0) {
var title = $html.find(".foundation-form-response-title").next().html();
var message = $html.find(".foundation-form-response-description").next().html();
ui.alert(title, message, "error");
return;
}
}
ui.alert(error, errorThrown, "error");
});
}
function submit(wizard) {
var flag = true;
if (flag == true && (wizard.prop("template").value.indexOf("/apps/myproject/templates/testTemplate") >= 0)) {
$.ajax({
url: "/bin/someservletpath/submit",
method: "GET",
data: {
url: wizard.prop("parentPath").value,
pageTemplate: wizard.prop("template").value
},
dataType: "html"
}).done(function(res) {
wizard.prop("parentPath").value = res;
createPage(wizard);
}).fail(function(res) {
ui.alert(res, "error");
});
} else {
createPage(wizard);
}
}
$(document).on("submit", ".cq-siteadmin-admin-createpage", function(e) {
e.preventDefault();
submit($(this));
});
})(window, document, Granite, Granite.$);
As mentioned in #2 above the category of clientlibs should be "app.myproject.createpagewizard" and associated to create page wizard via head component overlaying.
In order to attach this new clientlibs to create page wizard, you need to overlay the wizard's head component and add your custom category i.e. "app.myproject.createpagewizard" as shown in below diagram-
3. Customize the confirmation Step-3
Once you have submitted the create page form, there comes a popup window for confirmation, if you want to modify the form submit behavior then you can do following customization-
(function(window, document, Granite, $) {
"use strict";
var ui = $(window).adaptTo("foundation-ui");
function createPage(wizard) {
$.ajax({
type: wizard.prop("method"),
url: wizard.prop("action"),
contentType: wizard.prop("enctype"),
data: wizard.serialize()
}).done(function(html) {
var $html = $(html);
var edit = $html.find("a.cq-siteadmin-admin-createpage-edit");
window.location = edit.prop("href");
}).fail(function(xhr, error, errorThrown) {
if (error === "error") {
var $html = $(xhr.responseText);
if ($html.find(".foundation-form-response-status-code").length > 0) {
var title = $html.find(".foundation-form-response-title").next().html();
var message = $html.find(".foundation-form-response-description").next().html();
ui.alert(title, message, "error");
return;
}
}
ui.alert(error, errorThrown, "error");
});
}
function submit(wizard) {
var flag = true;
if (flag == true && (wizard.prop("template").value.indexOf("/apps/myproject/templates/testTemplate") >= 0)) {
$.ajax({
url: "/bin/someservletpath/submit",
method: "GET",
data: {
url: wizard.prop("parentPath").value,
pageTemplate: wizard.prop("template").value
},
dataType: "html"
}).done(function(res) {
wizard.prop("parentPath").value = res;
createPage(wizard);
}).fail(function(res) {
ui.alert(res, "error");
});
} else {
createPage(wizard);
}
}
$(document).on("submit", ".cq-siteadmin-admin-createpage", function(e) {
e.preventDefault();
submit($(this));
});
})(window, document, Granite, Granite.$);
As mentioned in #2 above the category of clientlibs should be "app.myproject.createpagewizard" and associated to create page wizard via head component overlaying.
HiVivek,
ReplyDeleteI have a need set components in sidekick according to our component list. By default AEM supports alphabetical order to show components and this list needs to be changed.
Thanks.
HiVivek,
ReplyDeleteI have a need set components in sidekick according to our component list. By default AEM supports alphabetical order to show components and this list needs to be changed.
Thanks.
Here you can see line #442 in file- /libs/cq/ui/widgets/source/widgets/wcm/ComponentList.js
DeleteFunction cs.sort("ASC", function(a, b) is doing the sorting. You need to override this in order to change the OOTB.
Hi Neeraj,
ReplyDeleteI remember there is one js - sidekick.js (Path- /libs/cq/ui/widgets/source/widgets/wcm/Sidekick.js)which has rendering script for sidekick. Look at that, it will give you idea on how to overwrite the component list rendering.
Thanks,
Vivek