Ensures macro and urls are not parsed in the ItemRenderer when a content item is assigned since that parsing will occur with the value converters

This commit is contained in:
Shannon
2013-12-10 09:59:13 +11:00
parent 103e226b51
commit 94db371234
2 changed files with 36 additions and 7 deletions

View File

@@ -77,17 +77,30 @@ namespace umbraco
}
else
{
if (elements[_fieldName] != null && !string.IsNullOrEmpty(elements[_fieldName].ToString()))
//check for published content and get its value using that
if (publishedContent != null)
{
_fieldContent = elements[_fieldName].ToString().Trim();
var pval = publishedContent.GetPropertyValue(_fieldName);
var rval = pval == null ? string.Empty : pval.ToString();
_fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval;
}
else if (!string.IsNullOrEmpty(helper.FindAttribute(attributes, "useIfEmpty")))
else if (elements[_fieldName] != null && string.IsNullOrEmpty(elements[_fieldName].ToString()) == false)
{
//get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent)
_fieldContent = elements[_fieldName].ToString().Trim();
}
//now we check if the value is still empty and if so we'll check useIfEmpty
if (string.IsNullOrEmpty(_fieldContent))
{
if (elements[helper.FindAttribute(attributes, "useIfEmpty")] != null && !string.IsNullOrEmpty(elements[helper.FindAttribute(attributes, "useIfEmpty")].ToString()))
if (string.IsNullOrEmpty(helper.FindAttribute(attributes, "useIfEmpty")) == false)
{
_fieldContent = elements[helper.FindAttribute(attributes, "useIfEmpty")].ToString().Trim();
if (elements[helper.FindAttribute(attributes, "useIfEmpty")] != null && string.IsNullOrEmpty(elements[helper.FindAttribute(attributes, "useIfEmpty")].ToString()) == false)
{
_fieldContent = elements[helper.FindAttribute(attributes, "useIfEmpty")].ToString().Trim();
}
}
}
}
}
}

View File

@@ -75,7 +75,18 @@ namespace umbraco.presentation.templateControls
// handle text before/after
xsltTransformedOutput = AddBeforeAfterText(xsltTransformedOutput, helper.FindAttribute(item.LegacyAttributes, "insertTextBefore"), helper.FindAttribute(item.LegacyAttributes, "insertTextAfter"));
string finalResult = xsltTransformedOutput.Trim().Length > 0 ? xsltTransformedOutput : GetEmptyText(item);
writer.Write(TemplateUtilities.ResolveUrlsFromTextString(finalResult));
//Don't parse urls if a content item is assigned since that is taken care
// of with the value converters
if (item.ContentItem == null)
{
writer.Write(TemplateUtilities.ResolveUrlsFromTextString(finalResult));
}
else
{
writer.Write(finalResult);
}
}
catch (Exception renderException)
{
@@ -149,6 +160,11 @@ namespace umbraco.presentation.templateControls
/// <param name="item">The item.</param>
protected virtual void ParseMacros(Item item)
{
//Don't parse macros if there's a content item assigned since the content value
// converters take care of that
if (item.ContentItem != null) return;
// do nothing if the macros have already been rendered
if (item.Controls.Count > 0)
return;