I know that in Tridion 2013 there is a flag in the ambient data framework which informs the website application whenever session preview is requested. However, i would also like to know when the experience manager itself is open and the site runs in its iframe inside. I have considered doing some javascript coding (detect the iframe in javascript and act accordingly) but i would much rather do this server-side. I do know that, when an editor opens up the experience manager, the page is reloaded.

Anyone have any ideas, or know any headers being set when the experience manager is active?

Regards,

Rogier

Try this in javascript.

if (typeof $display === "object" && $display.getView().getId() === "EditorView") {
    //Experience Manager is enabled
}

Try this in C#, this also works in Tridion 2011.

string sessionPreviewToken = "taf:claim:contentdelivery:webservice:preview:sessionid";

ClaimStore claimStore = AmbientDataContext.CurrentClaimStore;

Dictionary<Uri, object> claims = (Dictionary<Uri, object>)claimStore.GetAll();
Uri sessionTokenUri = new Uri(sessionPreviewToken);

if (claims.ContainsKey(sessionTokenUri)) {
    // Experience Manager is enabled with session preview.
}
  • So that's either using javascript, or detecting session preview ... no clue on how to detect just the experience manager interface server-side? – Rogier Oudshoorn Aug 13 '13 at 14:20
  • You can use some code like this as well if (Tridion.Web.UI.Core.ConfigurationManager.Editors["SiteEdit"] != null) {}, it will tell you that you have a SiteEdit editor configured, not sure if that will work in non-GUI extensions projects. – Eric Huiza Aug 13 '13 at 14:25
  • I'm actually unable to get the $display work from the Staging website, since it's not an object which is available on the staging website, only available in the XPM site. And I cannot even check top.$display since my domains/ports do not match (Staging vs XPM) – Bart Koopman Aug 13 '13 at 14:42
  • Ah! I am not attempting a UI extension into the CME, i'm looking to enchance my staging site. Unless of course, i could use a UI extension to set such a header myself ... – Rogier Oudshoorn Aug 13 '13 at 15:00
  • So the enhancements should only show when Staging is viewed in XPM? Would session preview-specific template code work? I'd be interested in the use case. We have some more ways to manipulate Staging's markup with XPM in this question about disabling links. – Alvin Reyes Aug 23 '13 at 16:34

I'm unaware of any headers being sent, apart from the referer of course, on opening Experience Manager, the following URL is opened http://your.cms.url/WebUI/Editors/SiteEdit/Views/Editor.aspx#url=http%3A%2F%2Fyour.staging.url%2Fpath%2Fpage.html

The referer of your request on the Staging website is then set to http://your.cms.url/WebUI/Editors/SiteEdit/Views/Editor.aspx

But when the Page is reloaded to update the preview (Session Preview), the referrer will just point to itself again.

What I used myself is a bit of Javascript to detect if the Page is loaded in a frame, assuming it is loaded in the XPM view. It's a bit dodgy (no guarantee against false positives) but the best I could find to easily detect if you were loaded inside XPM.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.