Try our conversational search powered by Generative AI!

DOPE mode?

Vote:
 

How can i find out in CMS 5 R2 if the current page is viewed in DOPE mode or not?

I have a script that replaces some text with images - making the DOPE mode useless...
So I would like to only run this script when not in DOPE mode.

Is this possible?

#35337
Dec 07, 2009 12:44
Vote:
 
#35339
Edited, Dec 07, 2009 13:37
Vote:
 

Something messed up my post, however found this link in the FAQ: http://world.episerver.com/FAQ/Items/Is-it-possible-to-determine-if-the-actual-page-is-in-DOPE-mode/

But it seems a bit old though :)

#35342
Edited, Dec 07, 2009 13:40
Vote:
 

I don't get your link to work - I get redirected back to this page.

#35344
Dec 07, 2009 13:51
Vote:
 

Sorry, it should work now.

#35345
Dec 07, 2009 13:55
Vote:
 

Hmmm... First of all, the updated version:

        private static bool IsDope(ControlCollection controls)
        {
            foreach (Control control in controls)
            {
                if (control.HasControls() && IsDope(control.Controls))
                    return true;

                var prop = control as EPiServer.Web.WebControls.Property;

                if (prop == null)
                    continue;

                if (!prop.EditMode && prop.Editable)
                    return true;
            }
            return false;
        }

        private bool IsDope()
        {
            return IsDope(Page.Controls);
        }

The code editor is horrible - I don't get my code to show correctly here.

But is seems that what I get here is whether the page is being edited or not... So when I use this, my script is not run in DOPE-mode (=OK) and not run in EDIT-mode (=WRONG) and not run in NOT-LOGGED-IN-MODE (=OK).

It seems weird to me that there's no simple way to check this - the controls must be rendered according to the situation...

#35348
Edited, Dec 07, 2009 14:14
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.