currentStyle. is returning null in c

2019-09-17 07:37发布

问题:

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.



标签: aem sightly