Hello All,
I have a scenario where I need to change the default values in a dialog based on a template type.
Example:
If I drop my component onto Template 1, the default values of 2 fields in the dialog be 30,40 and when I drag and drop the same component on to a different template then the values in the dialog needs to be changed to 30,40
Template 1:
Template 2:
Thanks,
Adithya.
Solved! Go to Solution.
Views
Replies
Total Likes
Yes, you can
please check https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/javadoc/co...
${cqDesign.propertyName}
@adithyaa4585051, It would be better to do the checks from backend and provide overrides in the dialogs for the authors.
But if would like to maintain it only at dialog level, we might have to manipulate few things in the dialog listeners.
Create a dialog listener, get the current page json and retrieve the resourceType or template name and you can add the required values in the fields based on the template/resourcetype comparison.
Sample Markup:
$(document).on("dialog-ready", function() {
//Hard coded the path
var url = "http://localhost:4502/content/aem-flash/en/jcr:content.json";
var templateName = "";
$.getJSON(url, function(json) {
templateName = json['cq:template'];
console.log('templateName is {}', templateName);
// Check the template / resource type and update the values in dialog
});
});
But, if you do this way, this might override the second time if the author updates the value earlier, so you may have to set a condition to update them only when the values are not present(Ideally the first time we dragged and dropped the component)
I would suggest, to do the checks from the backend and provide overrides for author instead of the above approach.
You can create a granite:rendercondition where you can check for the template type and set the default value.
Search rendercondition in crx/de search to see some OOTB samples. eg. /libs/cq/gui/components/renderconditions
Yes, you can
please check https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/javadoc/co...
${cqDesign.propertyName}
Views
Likes
Replies