Expand my Community achievements bar.

SOLVED

When putting a custom component inside an experience fragment, wcmmode.edit is false even in authoring mode.

Avatar

Level 2

I have a custom component whose htl template uses wcmmode.edit to conditionally render content.

 

When outside of an experience fragment, the wcmmode.edit works. But when I put it inside an experience fragment and link to the XF from a page, wcmmode.edit always resolves to false.

 

Am I using experience fragment incorrectly or something? Should experience fragment be only static content. Otherwise, how can I get the wcmmode.edit to work properly? 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @alankzp ,
${wcmmode.edit}" option is true when you are in edit mode. When you are editing the experience fragment that property will return true as you are expecting.
But when you are using in a page or iParsys the inner content is actually disabled and not in edit mode. 
That means you can not detect Author/Publish mode using slightly.

If you must need to detect it then you can take the help of Sling Model Class.

@Inject
private SlingSettingsService slingSettingsService;

boolean isAuthor = slingSettingsService.getRunModes().contains("author");

// Proper Getter and Setter
// Use in HTL

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hello @alankzp ,
${wcmmode.edit}" option is true when you are in edit mode. When you are editing the experience fragment that property will return true as you are expecting.
But when you are using in a page or iParsys the inner content is actually disabled and not in edit mode. 
That means you can not detect Author/Publish mode using slightly.

If you must need to detect it then you can take the help of Sling Model Class.

@Inject
private SlingSettingsService slingSettingsService;

boolean isAuthor = slingSettingsService.getRunModes().contains("author");

// Proper Getter and Setter
// Use in HTL