To get CQ page properties inside javascript you can use core CQ JS API. It can be convenient if you need to get this information inside your custom JS widgets.
var pageData = CQ.HTTP.get(CQ.HTTP.externalize(CQ.utils.WCM.getPagePath() + "/jcr:content.json"));
After that you can retrieve any property you need (assuming it's present in JCR):
var pageData = CQ.HTTP.get(CQ.HTTP.externalize(CQ.utils.WCM.getPagePath() + "/jcr:content.json"));
After that you can retrieve any property you need (assuming it's present in JCR):
var resourceType = pageData ? CQ.Util.formatData(CQ.HTTP.eval(pageData))['sling:resourceType'] : null;
Please do not overuse it because it invokes additional ajax call to server. It's OK to use it in edit mode on author instance.
Comments
Post a Comment