Hi Team,
${wcmmode.design} is giving false even in design mode.
Please help me to resolve the issue.
Aem version - 6.4
Thanks,
Sandeep.
Solved! Go to Solution.
Views
Replies
Total Likes
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>
<sly data-sly-test="${wcmmode.design}"></sly> - this syntax should work
can you give your complete html source here
Views
Replies
Total Likes
I don't think so we can get design mode in AEM6.4
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...
Is there anywany to get design mode in slightly?
Views
Replies
Total Likes
Hi @arunpatidar ,
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;
}
Thanks,
Sandeep.
Views
Replies
Total Likes
@Deleted Accountif 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
Views
Replies
Total Likes
It is not working for me as well and I noticed the cookies are not getting updated but updating in classic mode.
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
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>
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()
Views
Likes
Replies
Views
Likes
Replies