currentStyle.<propertyName> is returning null in cq5 publisher, which is working perfectly fine in author

白昼怎懂夜的黑 提交于 2019-12-13 07:59:33

问题


I am using sightly to access the design dialog properties for a component. something like

<span data-sly-test="${currentStyle.delimiter}">${currentStyle.delimiter}</span>

but all I am getting is an empty string.

I tried to resolve the issue by trying out the following.

  1. Activating the design node
  2. Deleting the page and creating a new page.
  3. Deleting components and dragging and dropping the component again on the page.
  4. I checked the JSON output of currentDesign and all the values am trying to access are available there.

回答1:


You have two options

  1. In preview/ publish mode fetch the design values via currentDesign.getJSON(), parse the value returned from that and then key into the values You want from the Json object.
  2. You may solve this by removing one line of code from your template head.js. if you are inheriting any template from one of the "/libs" ( sightly) page and there head.js will be having below line of code so you can just overlay head.js in your template and commented out below line of code.

if (wcmmode.disabled) { request.setAttribute(Packages.com.day.cq.wcm.api.components.ComponentContext. BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, true); }

Comment out this and everything was back to normal.



来源:https://stackoverflow.com/questions/30122158/currentstyle-propertyname-is-returning-null-in-cq5-publisher-which-is-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!