Some pages in my CQ5.5 application are being made with no 'jcr:content' node. Since the node does not exist the properties of these particular pages do not exist and cannot be fixed by users. I want to add a button that will allow a user to add the node if it is missing. I have been able to add a button "Fix Properties" that has a custom function attached that retrieves the existing node and I am able to check for the existence of the jcr:content node. I cannot find documentation anywhere on how to make a node from scratch. I figured this would be a common thing but there is very little to find about it.
I found this documentation for Nodes in general and most of the functions work but so far no dice: http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.Ext.data.Node
and so far have this function. Each attempt was done separately:
CQ.wcm.SiteAdmin.createProperties = function() {
var path = this.getCurrentPath();
var tree = CQ.Ext.getCmp(this.id + "-tree");
//var nodet = tree.getSelectionModel().getSelectedNode(); //gets the selected node
//nodet.childNodes[i] skips over jcr:content nodes
var nodej = CQ.Util.eval(path + '.2.json'); //am currently using this to get the node data instead
if(typeof nodej['jcr:content'] == 'undefined') //If the jcr:content node does not exist
{
//Attempt 1:
nodej['jcr:content'] = new CQ.wcm.Node({
jcr:primaryType: "cq:PageContent",
jcr:title: "title"});
//Attempt 2:
nodej['jcr:content'] = new Node({ //Note no 'CQ.wcm'
jcr:primaryType: "cq:PageContent",
jcr:title: "title"});
//Attempt 3:
nodej.appendChild( new CQ.wcm.Node({
jcr:primaryType: "cq:PageContent",
jcr:title: "title"}));
//Attempt 4:
nodej.appendChild( new CQ.wcm.Node({
Name : "jcr:content",
jcr:primaryType: "cq:PageContent",
jcr:title: "title"}));
}
};
None of the above attempts do anything but it is the closest thing I could think of.
I did find this question: How to add new property to JCR node through CQ.extjs? but it did nothing visible and it is also about adding to an existing node.