currentStyle.getPath() not returning complete path | Community
Skip to main content
Level 2
Mar 20, 2019 3:43 AM UTC
Solved

currentStyle.getPath() not returning complete path

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Gaurav-Behl
Gaurav-BehlAccepted solution
Level 10
Mar 21, 2019 2:26 PM UTC

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

7 replies

Gaurav-Behl
Gaurav-BehlAccepted solution
Level 10
Mar 21, 2019 2:26 PM UTC

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

Translate
AlbinIs1Author
Level 2
Mar 21, 2019 1:55 PM UTC

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

Translate
joerghoh
Employee
Mar 20, 2019 5:43 PM UTC

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

Translate
paradox8071
Level 2
Mar 20, 2019 1:45 PM UTC

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

}

Translate
smacdonald2008
Level 10
Mar 20, 2019 1:31 PM UTC

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,

Translate
AlbinIs1Author
Level 2
Mar 20, 2019 12:36 PM UTC

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

AEM version is - 6.4.3.0

Regards

Albin I

Translate
arunpatidar
New Participant
Mar 20, 2019 11:58 AM UTC

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

What AEM Version are you using?

Translate
Arun Patidar