fixes exception when rendering macros in rte in back office.

This commit is contained in:
Shannon
2015-01-30 10:59:11 +11:00
parent 3ea7f8a226
commit f32e47a363
2 changed files with 17 additions and 3 deletions

View File

@@ -102,6 +102,8 @@ namespace Umbraco.Web.Macros
public string Execute(MacroModel macro, INode node)
{
if (node == null) return string.Empty;
var umbCtx = _getUmbracoContext();
//NOTE: This is a bit of a nasty hack to check if the INode is actually already based on an IPublishedContent
// (will be the case when using LegacyConvertedNode )

View File

@@ -23,6 +23,7 @@ using Umbraco.Core.Events;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Macros;
using Umbraco.Core.Models;
using Umbraco.Core.Xml.XPath;
using Umbraco.Core.Profiling;
using umbraco.interfaces;
@@ -33,7 +34,6 @@ using Umbraco.Web.Models;
using Umbraco.Web.Templates;
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.macro;
using umbraco.cms.businesslogic.member;
using umbraco.DataLayer;
using umbraco.NodeFactory;
using umbraco.presentation.templateControls;
@@ -42,6 +42,9 @@ using Content = umbraco.cms.businesslogic.Content;
using Macro = umbraco.cms.businesslogic.macro.Macro;
using MacroErrorEventArgs = Umbraco.Core.Events.MacroErrorEventArgs;
using System.Linq;
using File = System.IO.File;
using MacroTypes = umbraco.cms.businesslogic.macro.MacroTypes;
using Member = umbraco.cms.businesslogic.member.Member;
namespace umbraco
{
@@ -1849,10 +1852,19 @@ namespace umbraco
{
//Get the current content request
var content = UmbracoContext.Current.PublishedContentRequest != null
IPublishedContent content;
if (UmbracoContext.Current.IsFrontEndUmbracoRequest)
{
content = UmbracoContext.Current.PublishedContentRequest != null
? UmbracoContext.Current.PublishedContentRequest.PublishedContent
: null;
}
else
{
var pageId = UmbracoContext.Current.PageId;
content = pageId.HasValue ? UmbracoContext.Current.ContentCache.GetById(pageId.Value) : null;
}
return content == null ? null : LegacyNodeHelper.ConvertToNode(content);
}