Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saulovenancio/8688966 to your computer and use it in GitHub Desktop.
Save saulovenancio/8688966 to your computer and use it in GitHub Desktop.
Set up your file structure something like this:
/apps/your-site/components/page
-> yourPage
-> clientlibs
-> js
-> customSidekickDialog.js
-> .content.xml
-> js.txt
-> customDialog.xml
-> ...
;(function(CQ){
var DIALOG_PATH = '/apps/your-project/path/to/customDialog.xml';
var DIALOG_PROPS = '/jcr:content/were/dialog/properties/should/be/stored';
// add dialog to default actions
CQ.wcm.Sidekick.DEFAULT_ACTIONS.push({
context: CQ.wcm.Sidekick.PAGE,
text: 'Title of your dialog in sidekick',
handler: function() {
// set up dialog configuration
var dialogConfig = CQ.WCM.getDialogConfig(DIALOG_PATH);
dialogConfig.success = function(form, action){
// reload page on dialog success
CQ.Util.reload(CQ.WCM.getContentWindow());
};
dialogConfig.failure = function(form, action){
// alert user when dialog fails
var resp = CQ.HTTP.buildPostResponseFromHTML(action.response);
CQ.Ext.Msg.alert(response.headers[CQ.HTTP.HEADER_MESSAGE]);
};
// prepare and show dialog
var dialog = CQ.WCM.getDialog(dialogConfig, DIALOG_PATH);
dialog.loadContent(this.getPath() + DIALOG_PROPS);
dialog.setTitle('Title of your dialog in dialog window');
dialog.show();
}
});
})(CQ);
// replace sidekick launch in init.jsp with this
CQ.WCM.launchSidekick("<%= currentPage.getPath() %>", {
propsDialog: "<%= dlgPath == null ? "" : dlgPath %>",
locked: <%= currentPage.isLocked() %>,
previewReload: "true",
actions: CQ.wcm.Sidekick.DEFAULT_ACTIONS // make sure actions is explicitly specified
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment