Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Zweben 266 posts 750 karma points
    Dec 18, 2019 @ 14:59
    David Zweben
    0

    Strange issue getting values from certain pages

    I'm working on a tool that exports page content. It is looping through page properties and converting them to strings, but I'm hitting a strange issue with a specific Rich Text Editor property on certain pages.

    On some nodes of my doctype "standardPage", the RTE property "bodyText" will correctly return a string via the following code:

    stringValue = node.Value<IHtmlString>(propertyAlias).ToString();
    

    On other nodes of the same doctype, however, I get the following error:

    System.ArgumentNullException: 'Value cannot be null. 
    Parameter name: doc'
    

    The nodes giving this error do in fact have RTE content in the bodyText property, and other RTE properties on the same node seem to work.

    I have multiple languages configured on my site, and the StandardPage doctype has "Allow varying by culture" enabled, but the "Body Text" property does not have "Allow varying by culture" enabled, and I have tried every fallback and language setting on the .Value method that I could think of, with none working as I would expect.

    Also, I am outputting this same "bodyText" property value on the doctype's template without issue, and in fact I borrowed the node.Value<IHtmlString>(propertyAlias) code from the doctype's Models Builder generated model code.

    This is driving me crazy... any idea what's going on?

  • David Zweben 266 posts 750 karma points
    Dec 18, 2019 @ 15:48
    David Zweben
    0

    An update: after some more troubleshooting, I found that it happens when a macro is embedded in the RTE. This appears to happen with any macro whatsoever, even if it doesn't inherit from Umbraco.Web.Macros.PartialViewMacroPage and only contains a hard-coded string.

    I added an issue to the tracker here.

    If anyone has suggestions on a workaround to use temporarily, though, that would be great.

Please Sign in or register to post replies

Write your reply to:

Draft