How to find the authoring modes like edit, trageting or preview in javascript or by using Useapi. Is it possbile to find without using the cookies.
Solved! Go to Solution.
Views
Replies
Total Likes
WCMMode can be captured in Sightly or Java code as follows:
Hey, Why you want to do it with UseApi, if you can do it with sightly code.
Can you tell me if any specific reason?
"<div data-sly-test="${wcmmode.edit}">
edit...
</div>
<div data-sly-test="${wcmmode.preview}">
preview...
</div>"
Cheers,
Prince
Hi @Chandanhindustani ,
Another option, if you don't want to check cookie is to may be use data-attribute
<body data-wcm-mode="${wcmmode.toString}">.....</body>
$(document.body).attr('data-wcm-mode') === "DISABLED"){
//do something
}
Views
Replies
Total Likes
@Chandanhindustani Easiest way is to identify runmode in Sightly and pass to useAPI rather than put complex logics in useapi, u can also inject the identified wcmmode as class or data attribute store at body/container level to identify using Javascript.
WCMMode can be captured in Sightly or Java code as follows:
It is doable in use api but does not make any sense for just finding wcmmode. You can use wcmmode global object and inject mode as data-attribute. But on publish, there is always one mode.
I am sharing the Javascript Use-API example , in case if really want to try -
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies