From 2161ec98b0fcb408aa9e24b0ef7a9ecbc67538c5 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 20 Jun 2013 11:25:33 +1000 Subject: [PATCH] Fixes: #U4-2324 - Umbraco.Field will now work with custom routed pages. --- src/Umbraco.Web/UmbracoHelper.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web/UmbracoHelper.cs b/src/Umbraco.Web/UmbracoHelper.cs index 2df598dce3..6c3dc09961 100644 --- a/src/Umbraco.Web/UmbracoHelper.cs +++ b/src/Umbraco.Web/UmbracoHelper.cs @@ -319,11 +319,19 @@ namespace Umbraco.Web LegacyAttributes = attributesForItem }; - //this is here to figure out if this request is in the context of a partial - if (_umbracoContext.PublishedContentRequest.PublishedContent.Id != currentPage.Id) + //here we are going to check if we are in the context of an Umbraco routed page, if we are we + //will leave the NodeId empty since the underlying ItemRenderer will work ever so slightly faster + //since it already knows about the current page. Otherwise, we'll assign the id based on our + //currently assigned node. The PublishedContentRequest will be null if: + // * we are rendering a partial view or child action + // * we are rendering a view from a custom route + if (_umbracoContext.PublishedContentRequest == null + || _umbracoContext.PublishedContentRequest.PublishedContent.Id != currentPage.Id) + { item.NodeId = currentPage.Id.ToString(); - - + } + + var containerPage = new FormlessPage(); containerPage.Controls.Add(item);