I have the following code base to share with you guys to display pages that are retrieved using the query builder using an AJAX call. We must pass the URL and parameters to retrieve the child pages from the URL that we provide.
I put some console.log to track the values โโof each state. replace it with your design.
<featurearticles jcr:primaryType="cq:Widget" fieldLabel="Article Pages" itemId="selectauthorId" name="./authorselect" type="select" xtype="selection"> <options jcr:primaryType="cq:WidgetCollection"/> <listeners jcr:primaryType="nt:unstructured" loadcontent="function(box,value) { CQ.Ext.Ajax.request({ url: '/bin/querybuilder.json', success: function(response, opts) { console.log('Response from the ajax'); var resTexts = $.parseJSON(response.responseText); var selectopts = []; console.log(resTexts); $.each(resTexts.hits, function(key, page) { console.log(page); selectopts.push({value: page['path'], text:page['name']}); }); console.log(selectopts); box.setOptions(selectopts); }, params: { 'type' :'cq:Page', 'group.1_path' : '/content/<PROJECT_NAME>/Feature_Articles' } }); }" selectionchanged="function(box,value) { var panel = this.findParentByType('panel'); var articleTitle = panel.getComponent('articleTitleId'); CQ.Ext.Ajax.request({ url: value + '/_jcr_content/par/featurearticleintro.json', success: function(response, opts) { console.log('success now'); var resTexts = $.parseJSON(response.responseText); console.log(resTexts); }, failure: function(response, opts) { console.log('server-side failure with status code ' + response.status); } }); }"/> </featurearticles>
If you have an idea better than this, I would like to know about it.
Greetings
source share