Expand my Community achievements bar.

SOLVED

currentStyle.getPath() not returning complete path

Avatar

Community Advisor

Hello

The current currentStyle.getPath() not returning complete path in publisher but the same is working fine in Author instance.

e.g currentStyle.getPath() returning /etc/designs/default/jcr:content/homepage but the expected value is /etc/designs/default/jcr:content/homepage/testcomponent

any expert idea?

Regards

Albin I

1 Accepted Solution

Avatar

Correct answer by
Level 10

this snippet is used to remove extra decorator tags in publish server/preview mode on author. You may choose to remove this snippet or move the code "currentStyle.getPath()"/your component out of this block and test it.

Refer -

https://aemcorner.com/aem-how-to-remove-div-wrapper-from-component/

http://www.sotheanim.com/35-how-to-get-rid-of-decorative-div-wrapper-from-aem-component

(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, false) would remove wrapper DIV for all next rendered components until the request is run out or you explicitly disable it.

Since it removes the extra wrapper containers, it might be an issue with how you utilize it

View solution in original post

7 Replies

Avatar

Community Advisor

Can you check the path in preview mode and disabled mode on author?

What AEM Version are you using?



Arun Patidar

Avatar

Community Advisor

The path is looking fine in Author but the issue is observed in Publisher.

AEM version is - 6.4.3.0

Regards

Albin I

Avatar

Level 10

This does not make sense - as they are both the same software versions and same API call. Can you show your entire code so the community can see if they can spot something,

Avatar

Level 2

one thing that you can check is that you are not doing anything specific to publish mode in your code. i.e

if (wcmmode.disabled) {

          //something that effect currentStyle Path

}

Avatar

Employee Advisor

Hi,

it might be an issue with permissions. You probably can access /etc/designs but not the /etc/ node (AEM 6.4 comes with a new set of permissions, especially regarding /etc/). I would avoid to use that API call and someone will probably recommend to drop /etc/design completely because the design is no longer en vogue, but you are supposed to use the style system or more recent AEM versions ...

Jörg

Avatar

Community Advisor

Based on my further analysis it looks to be the path is different between Author and Publisher due to the below code

if (!getWcmMode().isEdit() && !getWcmMode().isDesign()) {

IncludeOptions.getOptions(getRequest(), true).forceSameContext(true);

getRequest().setAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, false);

}

But i am not able to understand why the currentStyle path is different due to the above code, can you please explain?

Regards

Albin I

Avatar

Correct answer by
Level 10

this snippet is used to remove extra decorator tags in publish server/preview mode on author. You may choose to remove this snippet or move the code "currentStyle.getPath()"/your component out of this block and test it.

Refer -

https://aemcorner.com/aem-how-to-remove-div-wrapper-from-component/

http://www.sotheanim.com/35-how-to-get-rid-of-decorative-div-wrapper-from-aem-component

(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, false) would remove wrapper DIV for all next rendered components until the request is run out or you explicitly disable it.

Since it removes the extra wrapper containers, it might be an issue with how you utilize it