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

Avatar

Avatar

Amitdeol

Avatar

Amitdeol

Amitdeol

15-10-2015

I checked that cq:designPath is same in author and publish but when I am using ${currentStyle.path} to get the design path in author and publish then there is a slight difference i.e.
author:
/etc/designs/default/jcr:content/default-page/par-main/column-control/par-col-1/breadcrumb
publish:
/etc/designs/default/jcr:content/default-page/column-control/par-col-1/breadcrumb
 I tried creating a new template with a new parsys say “par-main-1” but then “par-main-1” was missing in publisher.

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.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

purnendraSingh

Avatar

purnendraSingh

purnendraSingh

15-10-2015

I am not sure if this is product bug or not but I solved this by removing one line of code from my template head.js .

I was inheriting my template from one of the "/libs" ( sightly)  page and there head.js was having below line of code so I just overlayed head.js in my 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); 

    }

I commented out this and every thing was back to normal. 

Check your template and check if you have this code some where .

Answers (8)

Answers (8)

Avatar

Avatar

dorianhallward

Avatar

dorianhallward

dorianhallward

19-01-2016

Sorry Promilag - no update from me.  I didn't follow the solution marked above as my page templates are built with jsp, so i left the sightly js using currentDesign.getJSON() to get the required values.

Avatar

Avatar

promilag4786340

Avatar

promilag4786340

promilag4786340

14-01-2016

Hi,

 

Any updates on this issue. I am also facing the same issue in AEM 6.1 in sightly ?

Avatar

Avatar

dorianhallward

Avatar

dorianhallward

dorianhallward

15-10-2015

Thanks Purnendra,

Actually my page is built with jsps (resource super type, foundation/components/page), perhaps the init scripts, global jsp etc do something similar to the code in head.js for page templates built in sightly?  I'll take a look.

Avatar

Avatar

dorianhallward

Avatar

dorianhallward

dorianhallward

15-10-2015

I haven't tried this with jsp but I'm doing something similar in Sightly/ javascript and encountering the same issue.   I've had to resort to something similar to the above comments : in preview/ publish mode fetch the design values via currentDesign.getJSON(), parse the value returned from that and then key into the values I want from the Json object.

Is this confirmed as a bug or an issue?  Or should I be coding something differently for publish mode...

// ...wcm use javascript snippet var n, p; if(wcmmode == 'EDIT' || wcmmode == 'DESIGN'){ n = currentStyle.get("foo"); p = currentStyle.get("bar"); }else{ // n = currentStyle.get("foo"); // p = currentStyle.get("bar"); ...these method calls return null - what to do here? }

Avatar

Avatar

purnendraSingh

Avatar

purnendraSingh

purnendraSingh

15-10-2015

Yes.

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K
smacdonald2008

15-10-2015

Does this happen when you use JSP as opposed to Sightly? 

Avatar

Avatar

purnendraSingh

Avatar

purnendraSingh

purnendraSingh

15-10-2015

Note : Happens only if you are using this in sightly based templates. 

Avatar

Avatar

purnendraSingh

Avatar

purnendraSingh

purnendraSingh

15-10-2015

I am also facing same issue in currentStyle object in publish. My component is not using parsys and  it is a cq include in page

publish ,value of currentStyle is like  :/etc/designs/scholastic/campaign/email/jcr:content/reading-club-page

while on author it is  like /etc/designs/scholastic/campaign/email/jcr:content/reading-club-page/header-container/preheaderimage. 

I tried all steps given here but could not resolve this .

Is there a known solution for this ?