From eb093ca4a6bfb1e92f7146dbeaeebadc07698e94 Mon Sep 17 00:00:00 2001 From: "gerwin.bouwhuis" Date: Thu, 29 Oct 2015 13:23:43 +0100 Subject: [PATCH 1/3] change : find the correct alternative recursive field --- src/Umbraco.Web/umbraco.presentation/item.cs | 89 +++++++++----------- 1 file changed, 40 insertions(+), 49 deletions(-) diff --git a/src/Umbraco.Web/umbraco.presentation/item.cs b/src/Umbraco.Web/umbraco.presentation/item.cs index 720e2ba9de..1edc6cca17 100644 --- a/src/Umbraco.Web/umbraco.presentation/item.cs +++ b/src/Umbraco.Web/umbraco.presentation/item.cs @@ -62,60 +62,51 @@ namespace umbraco else { // Loop through XML children we need to find the fields recursive - if (helper.FindAttribute(attributes, "recursive") == "true") + var recursive = helper.FindAttribute(attributes, "recursive") == "true"; + + if (publishedContent == null) { - if (publishedContent == null) - { - var recursiveVal = GetRecursiveValueLegacy(elements); - _fieldContent = recursiveVal.IsNullOrWhiteSpace() ? _fieldContent : recursiveVal; - } - else - { - var pval = publishedContent.GetPropertyValue(_fieldName, true); - var rval = pval == null ? string.Empty : pval.ToString(); - _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; - } + var recursiveVal = GetRecursiveValueLegacy(elements); + _fieldContent = recursiveVal.IsNullOrWhiteSpace() ? _fieldContent : recursiveVal; + } + + //check for published content and get its value using that + if (publishedContent != null && (publishedContent.HasProperty(_fieldName) || recursive)) + { + var pval = publishedContent.GetPropertyValue(_fieldName, recursive); + var rval = pval == null ? string.Empty : pval.ToString(); + _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; } else { - //check for published content and get its value using that - if (publishedContent != null && publishedContent.HasProperty(_fieldName)) - { - var pval = publishedContent.GetPropertyValue(_fieldName); - var rval = pval == null ? string.Empty : pval.ToString(); - _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; - } - else - { - //get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent) - var elt = elements[_fieldName]; - if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false) - _fieldContent = elt.ToString().Trim(); - } - - //now we check if the value is still empty and if so we'll check useIfEmpty - if (string.IsNullOrEmpty(_fieldContent)) - { - var altFieldName = helper.FindAttribute(attributes, "useIfEmpty"); - if (string.IsNullOrEmpty(altFieldName) == false) - { - if (publishedContent != null && publishedContent.HasProperty(altFieldName)) - { - var pval = publishedContent.GetPropertyValue(altFieldName); - var rval = pval == null ? string.Empty : pval.ToString(); - _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; - } - else - { - //get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent) - var elt = elements[altFieldName]; - if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false) - _fieldContent = elt.ToString().Trim(); - } - } - } - + //get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent) + var elt = elements[_fieldName]; + if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false) + _fieldContent = elt.ToString().Trim(); } + + //now we check if the value is still empty and if so we'll check useIfEmpty + if (string.IsNullOrEmpty(_fieldContent)) + { + var altFieldName = helper.FindAttribute(attributes, "useIfEmpty"); + if (string.IsNullOrEmpty(altFieldName) == false) + { + if (publishedContent != null && (publishedContent.HasProperty(altFieldName) || recursive)) + { + var pval = publishedContent.GetPropertyValue(altFieldName, recursive); + var rval = pval == null ? string.Empty : pval.ToString(); + _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; + } + else + { + //get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent) + var elt = elements[altFieldName]; + if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false) + _fieldContent = elt.ToString().Trim(); + } + } + } + } ParseItem(attributes); From 93d89535aa55817b40f92358851cbb2abf0ac43d Mon Sep 17 00:00:00 2001 From: "gerwin.bouwhuis" Date: Thu, 29 Oct 2015 13:32:50 +0100 Subject: [PATCH 2/3] undo --- src/Umbraco.Web/umbraco.presentation/item.cs | 85 +++++++++++--------- 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/src/Umbraco.Web/umbraco.presentation/item.cs b/src/Umbraco.Web/umbraco.presentation/item.cs index 1edc6cca17..720e2ba9de 100644 --- a/src/Umbraco.Web/umbraco.presentation/item.cs +++ b/src/Umbraco.Web/umbraco.presentation/item.cs @@ -62,51 +62,60 @@ namespace umbraco else { // Loop through XML children we need to find the fields recursive - var recursive = helper.FindAttribute(attributes, "recursive") == "true"; - - if (publishedContent == null) + if (helper.FindAttribute(attributes, "recursive") == "true") { - var recursiveVal = GetRecursiveValueLegacy(elements); - _fieldContent = recursiveVal.IsNullOrWhiteSpace() ? _fieldContent : recursiveVal; - } - - //check for published content and get its value using that - if (publishedContent != null && (publishedContent.HasProperty(_fieldName) || recursive)) - { - var pval = publishedContent.GetPropertyValue(_fieldName, recursive); - var rval = pval == null ? string.Empty : pval.ToString(); - _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; + if (publishedContent == null) + { + var recursiveVal = GetRecursiveValueLegacy(elements); + _fieldContent = recursiveVal.IsNullOrWhiteSpace() ? _fieldContent : recursiveVal; + } + else + { + var pval = publishedContent.GetPropertyValue(_fieldName, true); + var rval = pval == null ? string.Empty : pval.ToString(); + _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; + } } else { - //get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent) - var elt = elements[_fieldName]; - if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false) - _fieldContent = elt.ToString().Trim(); - } - - //now we check if the value is still empty and if so we'll check useIfEmpty - if (string.IsNullOrEmpty(_fieldContent)) - { - var altFieldName = helper.FindAttribute(attributes, "useIfEmpty"); - if (string.IsNullOrEmpty(altFieldName) == false) + //check for published content and get its value using that + if (publishedContent != null && publishedContent.HasProperty(_fieldName)) { - if (publishedContent != null && (publishedContent.HasProperty(altFieldName) || recursive)) - { - var pval = publishedContent.GetPropertyValue(altFieldName, recursive); - var rval = pval == null ? string.Empty : pval.ToString(); - _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; - } - else - { - //get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent) - var elt = elements[altFieldName]; - if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false) - _fieldContent = elt.ToString().Trim(); - } + var pval = publishedContent.GetPropertyValue(_fieldName); + var rval = pval == null ? string.Empty : pval.ToString(); + _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; + } + else + { + //get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent) + var elt = elements[_fieldName]; + if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false) + _fieldContent = elt.ToString().Trim(); } - } + //now we check if the value is still empty and if so we'll check useIfEmpty + if (string.IsNullOrEmpty(_fieldContent)) + { + var altFieldName = helper.FindAttribute(attributes, "useIfEmpty"); + if (string.IsNullOrEmpty(altFieldName) == false) + { + if (publishedContent != null && publishedContent.HasProperty(altFieldName)) + { + var pval = publishedContent.GetPropertyValue(altFieldName); + var rval = pval == null ? string.Empty : pval.ToString(); + _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; + } + else + { + //get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent) + var elt = elements[altFieldName]; + if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false) + _fieldContent = elt.ToString().Trim(); + } + } + } + + } } ParseItem(attributes); From 697daab4d75f28a8bb2640af66f35094d26e4ff5 Mon Sep 17 00:00:00 2001 From: "gerwin.bouwhuis" Date: Thu, 29 Oct 2015 13:50:30 +0100 Subject: [PATCH 3/3] change :get the correct alternative recursive field --- src/Umbraco.Web/umbraco.presentation/item.cs | 89 +++++++++----------- 1 file changed, 40 insertions(+), 49 deletions(-) diff --git a/src/Umbraco.Web/umbraco.presentation/item.cs b/src/Umbraco.Web/umbraco.presentation/item.cs index 720e2ba9de..1edc6cca17 100644 --- a/src/Umbraco.Web/umbraco.presentation/item.cs +++ b/src/Umbraco.Web/umbraco.presentation/item.cs @@ -62,60 +62,51 @@ namespace umbraco else { // Loop through XML children we need to find the fields recursive - if (helper.FindAttribute(attributes, "recursive") == "true") + var recursive = helper.FindAttribute(attributes, "recursive") == "true"; + + if (publishedContent == null) { - if (publishedContent == null) - { - var recursiveVal = GetRecursiveValueLegacy(elements); - _fieldContent = recursiveVal.IsNullOrWhiteSpace() ? _fieldContent : recursiveVal; - } - else - { - var pval = publishedContent.GetPropertyValue(_fieldName, true); - var rval = pval == null ? string.Empty : pval.ToString(); - _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; - } + var recursiveVal = GetRecursiveValueLegacy(elements); + _fieldContent = recursiveVal.IsNullOrWhiteSpace() ? _fieldContent : recursiveVal; + } + + //check for published content and get its value using that + if (publishedContent != null && (publishedContent.HasProperty(_fieldName) || recursive)) + { + var pval = publishedContent.GetPropertyValue(_fieldName, recursive); + var rval = pval == null ? string.Empty : pval.ToString(); + _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; } else { - //check for published content and get its value using that - if (publishedContent != null && publishedContent.HasProperty(_fieldName)) - { - var pval = publishedContent.GetPropertyValue(_fieldName); - var rval = pval == null ? string.Empty : pval.ToString(); - _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; - } - else - { - //get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent) - var elt = elements[_fieldName]; - if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false) - _fieldContent = elt.ToString().Trim(); - } - - //now we check if the value is still empty and if so we'll check useIfEmpty - if (string.IsNullOrEmpty(_fieldContent)) - { - var altFieldName = helper.FindAttribute(attributes, "useIfEmpty"); - if (string.IsNullOrEmpty(altFieldName) == false) - { - if (publishedContent != null && publishedContent.HasProperty(altFieldName)) - { - var pval = publishedContent.GetPropertyValue(altFieldName); - var rval = pval == null ? string.Empty : pval.ToString(); - _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; - } - else - { - //get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent) - var elt = elements[altFieldName]; - if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false) - _fieldContent = elt.ToString().Trim(); - } - } - } - + //get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent) + var elt = elements[_fieldName]; + if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false) + _fieldContent = elt.ToString().Trim(); } + + //now we check if the value is still empty and if so we'll check useIfEmpty + if (string.IsNullOrEmpty(_fieldContent)) + { + var altFieldName = helper.FindAttribute(attributes, "useIfEmpty"); + if (string.IsNullOrEmpty(altFieldName) == false) + { + if (publishedContent != null && (publishedContent.HasProperty(altFieldName) || recursive)) + { + var pval = publishedContent.GetPropertyValue(altFieldName, recursive); + var rval = pval == null ? string.Empty : pval.ToString(); + _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval; + } + else + { + //get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent) + var elt = elements[altFieldName]; + if (elt != null && string.IsNullOrEmpty(elt.ToString()) == false) + _fieldContent = elt.ToString().Trim(); + } + } + } + } ParseItem(attributes);