Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Programatically Determine If Running CMS Desk or Site Manager View modes: 
User avatar
Member
Member
Peter - 1/23/2011 8:01:54 AM
   
Programatically Determine If Running CMS Desk or Site Manager
I have some UI customization (implemented in the App_Code/Global/CMS/CMSPageEvents.cs file in the AfterPageLoad event) that I would like to enable in the CMS Desk (for certain sites) but keep out the Site Administrator interface. The issue is is that the CMS Desk and the Site Manager share a lot of pages so you cannot assume a page under the /cmssitemanager folder means you are running in the Site Manager.

I've tried to use the CMS.CMSHelper.CMSContext.CurrentSite* set of properties assuming that these would tell me that no site is current (Site Manager) BUT, perhaps because I currently have only 1 site defined, this does not work. The objects contain valid site information while running under Site Manager.

So, the question is, is there a way to determine with certainty if you are running under Site Manager and/or CMS Desk? Note: ISGlobalAdministrator is true running under Site Manager or CMS Desk so that will not work.

Thanks!

User avatar
Member
Member
kentico_michal - 1/26/2011 6:45:02 AM
   
RE:Programatically Determine If Running CMS Desk or Site Manager
Hi Peter,

Regrettably, Kentico CMS does not provide property which would allow you to distinguish whether you are in CMS Desk or Site manager.
However, you could try to use CurrentURL property to get URL of the current page and if the current url contains CMSDesk value you are in CMS desk interface and vice versa:
CMS.GlobalHelper.UrlHelper.CurrentURL

Michal Legen,
Best regards

User avatar
Member
Member
StavrouM@dotcy.com.cy - 2/2/2011 4:07:08 AM
   
RE:Programatically Determine If Running CMS Desk or Site Manager
That won't work. The current URL will not return the parent frame url. The way to do it is by checking the CMSContext.ViewMode property. For example I have 3 panels in a page and I want them all visible in CMSDesk so that editors can change content. But I only want one of them on the live site, based on where the user clicks, so this is how I do it:


protected void Page_Load(object sender, EventArgs e) {
// If the user is in CMS desk then show all 3 panels
if ((CMSContext.ViewMode != CMS.PortalEngine.ViewModeEnum.LiveSite) && (CMSContext.ViewMode != CMS.PortalEngine.ViewModeEnum.Preview)) {
pnlStep1.Visible = true;
pnlStep2.Visible = true;
pnlStep3.Visible = true;
}
}

User avatar
Kentico Support
Kentico Support
kentico_radekm - 2/2/2011 7:32:44 AM
   
RE:Programatically Determine If Running CMS Desk or Site Manager
Hello.

Just for the others, this is complete enumeration of viewstates you can use:

namespace CMS.PortalEngine
{
// Summary:
// Page mode enumeration
public enum ViewModeEnum
{
// Summary:
// Live site mode
LiveSite = 0,
//
// Summary:
// Preview mode
Preview = 2,
//
// Summary:
// Edit mode - content editing
Edit = 3,
//
// Summary:
// Edit mode - content editing (editing disabled)
EditDisabled = 4,
//
// Summary:
// Edit mode - not current page
EditNotCurrent = 5,
//
// Summary:
// Edit mode with disabled controls - when not authorized or cannot edit
Design = 6,
//
// Summary:
// Design mode with disabled controls - for portal engine pages
DesignDisabled = 7,
//
// Summary:
// Edit form mode - for portal engine pages
EditForm = 8,
//
// Summary:
// Unknown / does not matter
Unknown = 9,
//
// Summary:
// Properties tab
Properties = 10,
//
// Summary:
// Product tab
Product = 11,
//
// Summary:
// User widgets mode
UserWidgets = 12,
//
// Summary:
// User widgets mode with disabled functionality (for preview mode)
UserWidgetsDisabled = 13,
//
// Summary:
// Group widgets mode
GroupWidgets = 14,
}
}


Best Regards,
Radek Macalik