Copied to clipboard

Flag this post as spam?

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


  • Vox 2 posts 72 karma points
    Oct 26, 2022 @ 09:52
    Vox
    0

    Macro in PublishedSearchResult Content throw ArgumentNullException

    Hello,

    I work with Umbraco version 8.9.1. I have a simple macro video to add local video (in Umbraco Media) in place of public url video. I also use a Search (IPublishedContentQuery) that return me a IEnumerable of PublishedSearchResult. It works well except when I use my macro video in a field, then the field (here body) throw an error : System.ArgumentNullException.

    Apparently it's the mapping that cannot be done. The property is in the item.Content.Property and the item.Content.HasValue(property) return true.

    public List<IPublishedProperty> CheckTheValues(PublishedSearchResult item, string searchValue)
    {
        foreach (var property in item.Content.Properties) // return me "body"
            {
                if (!item.Content.HasValue(property.Alias)) // HasValue return true
                    continue;
                var contentValue = item.Content.Value(property.Alias); // throw System.ArgumentNullException
                ...
            }
    }
    

    I suppose that's because the mapping cannot translate the macro in something known but it's awkward because I have the html code in my cache like <?UMBRACO_MACRO ... />.

    1. Is there a way to add an alternative content to the macro (not on the video tag), I think about alt property that exists on html img to write an alternative text if the image doesn't exists ?
    2. If not, is there a way to force to get the html code ? (to get the tag umbraco_macro in place of an error)
    3. If not, is there a way to ignore the "not understand" part tags of the content "body" ? so return all except this macro tag.
    4. If not, except with a try catch continue, is there a proper way to ignore this result from my search ?

    Thanks a lot !

  • Vox 2 posts 72 karma points
    Nov 17, 2022 @ 19:50
    Vox
    0

    Hello, no one have any idea, please. It's really blocking for me.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies