design mode in slightly

Avatar

Avatar
Validate 1
Level 4
Sandeep6
Level 4

Likes

56 likes

Total Posts

66 posts

Correct reply

15 solutions
Top badges earned
Validate 1
Give Back
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 1
Level 4
Sandeep6
Level 4

Likes

56 likes

Total Posts

66 posts

Correct reply

15 solutions
Top badges earned
Validate 1
Give Back
Boost 50
Boost 5
Boost 3
View profile
Sandeep6
Level 4

11-11-2020

Hi Team,

${wcmmode.design} is giving false even in design mode.

Please help me to resolve the issue.

Aem version - 6.4

 

Thanks,

Sandeep.

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 100
Level 6
snbaem
Level 6

Likes

115 likes

Total Posts

245 posts

Correct reply

36 solutions
Top badges earned
Boost 100
Springboard
Establish
Validate 25
Validate 10
View profile

Avatar
Boost 100
Level 6
snbaem
Level 6

Likes

115 likes

Total Posts

245 posts

Correct reply

36 solutions
Top badges earned
Boost 100
Springboard
Establish
Validate 25
Validate 10
View profile
snbaem
Level 6

12-11-2020

Hi @san can you try the code line below ? Otherwise what you have mentioned seems like should work too.. Below kind of logic seems to work for me

 

//Display test1 if in design mode or test2 in edit mode
<sly data-sly-test.author="${wcmmode.design}">test1</sly>
<sly data-sly-test.author="${wcmmode.edit}">test2</sly>

 

Answers (4)

Answers (4)

Avatar

Avatar
Boost 100
Level 6
snbaem
Level 6

Likes

115 likes

Total Posts

245 posts

Correct reply

36 solutions
Top badges earned
Boost 100
Springboard
Establish
Validate 25
Validate 10
View profile

Avatar
Boost 100
Level 6
snbaem
Level 6

Likes

115 likes

Total Posts

245 posts

Correct reply

36 solutions
Top badges earned
Boost 100
Springboard
Establish
Validate 25
Validate 10
View profile
snbaem
Level 6

13-11-2020

@Sandeep6 

Using below in java also gives "edit" for value of wcmMode when loaded the page in design mode.

 

WCMMode wcmMode = WCMMode.fromRequest(slingRequest); 

 

Also needed to refresh the page for the model to be invoked.

Something that worked was trying similar to below

 

slingRequest.getCookie("cq-editor-layer.page").getValue()

 

 
 

 

 

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,440 likes

Total Posts

3,312 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,440 likes

Total Posts

3,312 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

12-11-2020

are you able to see the design mode set in cookies?

could you try with java API https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/reference-materials/javadoc/co...

Sandeep6

Is there anywany to get design mode in slightly?

Sandeep6

Hi @Arun_Patidar ,

I have tried using java also. still no luck. Please find below for code. Here I am getting wcmmode as. EDIT even in design mode.

 

@Model(adaptables = SlingHttpServletRequest.class)
public class WCMModel {

private static Logger logger = LoggerFactory.getLogger(WCMModel.class);
@Inject
private SlingHttpServletRequest httpServletRequest;

private boolean isDesign;

@PostConstruct
protected void init() {
logger.info("wcmmode = " + WCMMode.fromRequest(httpServletRequest));
if (WCMMode.DESIGN == WCMMode.fromRequest(httpServletRequest)) {
isDesign = true;
}
logger.info("wcmmode 2= " + WCMMode.valueOf(String.valueOf(httpServletRequest.getAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME))));
if(WCMMode.DESIGN == WCMMode.valueOf(String.valueOf(httpServletRequest.getAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME)))){
isDesign = true;
}
}

public boolean isDesign() {
logger.info("wcmmode123 = " + isDesign);
return isDesign;
}

 

Capture.PNG

 

Thanks,

Sandeep.

snbaem

@Sandeepif it help this backend logic works for me 

 

@Model(adaptables = {SlingHttpServletRequest.class, Resource.class }, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)

public class TestModel {

    private static final Logger LOG = LoggerFactory.getLogger(TestModel.class);

    @Inject
    private Resource resource;

    @SlingObject
    private SlingHttpServletRequest slingRequest;

    @ValueMapValue(name = "id", injectionStrategy = InjectionStrategy.OPTIONAL)
    private String testid;

   

    @PostConstruct
    protected void initModel() {
       
        if (resource != null) {
           
            WCMMode wcmMode = WCMMode.fromRequest(slingRequest);
            if (wcmMode != null) {
                if (wcmMode == WCMMode.EDIT) {
                    
                    // EDIT logic
                } else if (wcmMode == WCMMode.DESIGN) {
                    //DESIGN logic
                }
            } else {
                LOG.warn("wcmmode is null. Not processing Resource at: " + resource.getPath());
            }
        }
    }
}

 

. The difference I see is @SlingObject annotation. On debug do you get the sling request object? 

Update: I was only using wcmmode.edit that's why it seemed to work. But actually for wcmmode.design the value is incorrect

Arun_Patidar

It is not working for me as well and I noticed the cookies are not getting updated but updating in classic mode.

 

Arun_Patidar_0-1605296593215.png

 

Arun_Patidar_1-1605296625517.png

 

snbaem
Checked after seeing @Arun's comment. I am seeing the cookie state same as him. wcmmode is still edit when switched to Design mode. If clicked on preview and then design, then the wcmmode is preview which is still incorrect.
Sandeep6
Hi arun, Do we have any workaround for this?

Avatar

Avatar
Validate 1
MVP
Umesh_Thakur
MVP

Likes

147 likes

Total Posts

157 posts

Correct reply

53 solutions
Top badges earned
Validate 1
Applaud 25
Ignite 3
Ignite 1
Give Back 5
View profile

Avatar
Validate 1
MVP
Umesh_Thakur
MVP

Likes

147 likes

Total Posts

157 posts

Correct reply

53 solutions
Top badges earned
Validate 1
Applaud 25
Ignite 3
Ignite 1
Give Back 5
View profile
Umesh_Thakur
MVP

11-11-2020

I don't think so we can get design mode in AEM6.4

Avatar

Avatar
Ignite 1
MVP
SureshDhulipudi
MVP

Likes

163 likes

Total Posts

174 posts

Correct reply

49 solutions
Top badges earned
Ignite 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile

Avatar
Ignite 1
MVP
SureshDhulipudi
MVP

Likes

163 likes

Total Posts

174 posts

Correct reply

49 solutions
Top badges earned
Ignite 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile
SureshDhulipudi
MVP

11-11-2020

<sly data-sly-test="${wcmmode.design}"></sly> - this syntax should work

can you give your complete html source here