Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Edit mode on Page for Experience fragements Header

Avatar

Avatar
Springboard
Level 7
Prince_Shivhare
Level 7

Likes

107 likes

Total Posts

393 posts

Correct Reply

63 solutions
Top badges earned
Springboard
Establish
Give Back 100
Boost 100
Validate 1
View profile

Avatar
Springboard
Level 7
Prince_Shivhare
Level 7

Likes

107 likes

Total Posts

393 posts

Correct Reply

63 solutions
Top badges earned
Springboard
Establish
Give Back 100
Boost 100
Validate 1
View profile
Prince_Shivhare
Level 7

27-05-2021

Hi All,

I want to get the edit mode of the page for a header which is an Experience fragment.

I am trying ${wcmmode.edit}, but every time I am getting false in the author URL.

Can anyone help me here how can I get the edit mode of the page in the Header.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Springboard
Level 7
Prince_Shivhare
Level 7

Likes

107 likes

Total Posts

393 posts

Correct Reply

63 solutions
Top badges earned
Springboard
Establish
Give Back 100
Boost 100
Validate 1
View profile

Avatar
Springboard
Level 7
Prince_Shivhare
Level 7

Likes

107 likes

Total Posts

393 posts

Correct Reply

63 solutions
Top badges earned
Springboard
Establish
Give Back 100
Boost 100
Validate 1
View profile
Prince_Shivhare
Level 7

01-06-2021

This code worked for me.
If you have experience fragment and want to check wcmmode on non-experience fragment page and you want to make everything work properly in edit mode, with ?wcmmode=disabled and without ?wcmmode( Live Url), then - 

function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
}
else
{
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1) {
end = dc.length;
}
}
return decodeURI(dc.substring(begin + prefix.length, end));
}

var myCookie = getCookie("wcmmode");
var params = window.location.search;

if( myCookie=='preview' || params=='?wcmmode=disabled' || myCookie==null){
// DISABLE MODE
}

 

Answers (2)

Answers (2)

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,348 likes

Total Posts

3,226 posts

Correct Reply

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

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,348 likes

Total Posts

3,226 posts

Correct Reply

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

28-05-2021

you can try changing the WCM mode based on the condition

e.g.

Changes the WCM mode:

 

 

 

Edit Mode
<header data-sly-resource="${'path/to/resource' @ wcmmode='edit'}"></header>
Other Mode
<header data-sly-resource="${'path/to/resource' @ wcmmode='disabled'}"></header>

e.g.
<header data-sly-resource="${'path/to/resource' @ wcmmode=wcmmode.edit?'edit':'disabled'}"></header>

 

 

Avatar

Avatar
Springboard
Level 6
snbaem
Level 6

Likes

90 likes

Total Posts

216 posts

Correct Reply

28 solutions
Top badges earned
Springboard
Establish
Validate 25
Validate 10
Validate 1
View profile

Avatar
Springboard
Level 6
snbaem
Level 6

Likes

90 likes

Total Posts

216 posts

Correct Reply

28 solutions
Top badges earned
Springboard
Establish
Validate 25
Validate 10
Validate 1
View profile
snbaem
Level 6

27-05-2021

@Prince_Shivhare 

I think the wcm mode is determined based on cookie, can you check what is in the cookie?

For such scenarios is it ok for you to use following condition ? (in case the goal is to determine if the page is loaded on author mode and not publish) 

${wcmmode.edit || wcmmode.preview}