alex-klock / razor-mediator-4-tridion

Automatically exported from code.google.com/p/razor-mediator-4-tridion
1 stars 4 forks source link

function IsSiteEditEnabled stopped working after topology installment #21

Open 093rakeshchoudhary opened 6 years ago

093rakeshchoudhary commented 6 years ago

Is there an alternative function which can work with web 8.5 and topology manager?

093rakeshchoudhary commented 6 years ago

I wrote below code for IsSiteEditEnabled to support topology publishing model- public bool IsSiteEditEnabled { get { if (!_cachedIsSiteEditEnabled) { if (_engine.PublishingContext != null || _engine.PublishingContext.PublicationTarget != null) { if (Session.ApiVersion.StartsWith("8.")) { // We're going to use new properties which are only available in CM 8.1 and higher. // To avoid having to reference CM 8.1 APIs (which won't bind on CM 7.1), we use dynamic types here. dynamic pubContext = _engine.PublishingContext; dynamic targetType = pubContext.TargetType; if (targetType != null && targetType.BusinessProcessType != null) { // New-style publishing Publication contextPublication = (Publication)((RepositoryLocalObject)_engine.PublishingContext.ResolvedItem.Item).ContextRepository; if (targetType.IsPreviewCapable(contextPublication)) { _isSiteEditEnabled = true; } return targetType.IsPreviewCapable(contextPublication); } else { _cachedIsSiteEditEnabled = true; return false; } }

                }
                _cachedIsSiteEditEnabled = true;
            }
            return _isSiteEditEnabled;
        }
    }