问题
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.
- Activating the design node
- Deleting the page and creating a new page.
- Deleting components and dragging and dropping the component again on the page.
- I checked the JSON output of currentDesign and all the values am trying to access are available there.
回答1:
You have two options
- 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.
- 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