Macro inside another macro, in the rich text editor
I currently have a document type with a rich text editor field, and a couple of macros with content pickers which allow you to select these documents. The macros should then display the content in the RTE in some way.
This mostly works fine, however an exception gets thrown if the content in the RTE also contains a macro, i.e. I'm trying to render a macro inside another macro. The exception is only thrown inside the RTE though, and the macros appear to display on the actual site fine.
The exception is thrown when I try to get the property from the modelsbuilder class for the document type, or when I call Value() on the IPublishedContent instance for the node that contains the "inner" macro.
Is it possible to render macros like this in the RTE, or should this be avoided?
The stack trace for the exception is:
System.ArgumentNullException: Value cannot be null.
Parameter name: doc
at Umbraco.Web.Macros.PublishedContentHashtableConverter..ctor(IPublishedContent doc) in D:\a\1\s\src\Umbraco.Web\Macros\PublishedContentHashtableConverter.cs:line 57
at Umbraco.Web.Macros.MacroRenderer.Render(String macroAlias, IPublishedContent content, IDictionary2 macroParams) in D:\a\1\s\src\Umbraco.Web\Macros\MacroRenderer.cs:line 206
at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.<>c__DisplayClass7_0.<RenderRteMacros>b__1(String macroAlias, Dictionary2 macroAttributes) in D:\a\1\s\src\Umbraco.Web\PropertyEditors\ValueConverters\RteMacroRenderingValueConverter.cs:line 64
at Umbraco.Web.Macros.MacroTagParser.ParseMacros(String text, Action1 textFoundCallback, Action2 macroFoundCallback) in D:\a\1\s\src\Umbraco.Web\Macros\MacroTagParser.cs:line 194
at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.RenderRteMacros(String source, Boolean preview) in D:\a\1\s\src\Umbraco.Web\PropertyEditors\ValueConverters\RteMacroRenderingValueConverter.cs:line 59
at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.Convert(Object source, Boolean preview) in D:\a\1\s\src\Umbraco.Web\PropertyEditors\ValueConverters\RteMacroRenderingValueConverter.cs:line 96
at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, Object inter, Boolean preview) in D:\a\1\s\src\Umbraco.Web\PropertyEditors\ValueConverters\RteMacroRenderingValueConverter.cs:line 76
at Umbraco.Core.Models.PublishedContent.PublishedPropertyType.ConvertInterToObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, Object inter, Boolean preview) in D:\a\1\s\src\Umbraco.Core\Models\PublishedContent\PublishedPropertyType.cs:line 221
at Umbraco.Web.PublishedCache.NuCache.Property.GetValue(String culture, String segment) in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\Property.cs:line 211
at Umbraco.Web.PublishedPropertyExtension.Value[T](IPublishedProperty property, String culture, String segment, Fallback fallback, T defaultValue) in D:\a\1\s\src\Umbraco.Web\PublishedPropertyExtension.cs:line 39
at Umbraco.Web.PublishedContentExtensions.Value[T](IPublishedContent content, String alias, String culture, String segment, Fallback fallback, T defaultValue) in D:\a\1\s\src\Umbraco.Web\PublishedContentExtensions.cs:line 169
at Umbraco.Web.PublishedModels.BaseWithContent.getContent() in C:\Workspace\People Hub\PeopleHub\AppData\Models\BaseWithContent.generated.cs:line 52
Macro inside another macro, in the rich text editor
I currently have a document type with a rich text editor field, and a couple of macros with content pickers which allow you to select these documents. The macros should then display the content in the RTE in some way.
This mostly works fine, however an exception gets thrown if the content in the RTE also contains a macro, i.e. I'm trying to render a macro inside another macro. The exception is only thrown inside the RTE though, and the macros appear to display on the actual site fine.
The exception is thrown when I try to get the property from the modelsbuilder class for the document type, or when I call Value() on the IPublishedContent instance for the node that contains the "inner" macro.
Is it possible to render macros like this in the RTE, or should this be avoided?
The stack trace for the exception is:
System.ArgumentNullException: Value cannot be null. Parameter name: doc at Umbraco.Web.Macros.PublishedContentHashtableConverter..ctor(IPublishedContent doc) in D:\a\1\s\src\Umbraco.Web\Macros\PublishedContentHashtableConverter.cs:line 57 at Umbraco.Web.Macros.MacroRenderer.Render(String macroAlias, IPublishedContent content, IDictionary
2 macroParams) in D:\a\1\s\src\Umbraco.Web\Macros\MacroRenderer.cs:line 206 at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.<>c__DisplayClass7_0.<RenderRteMacros>b__1(String macroAlias, Dictionary
2 macroAttributes) in D:\a\1\s\src\Umbraco.Web\PropertyEditors\ValueConverters\RteMacroRenderingValueConverter.cs:line 64 at Umbraco.Web.Macros.MacroTagParser.ParseMacros(String text, Action1 textFoundCallback, Action
2 macroFoundCallback) in D:\a\1\s\src\Umbraco.Web\Macros\MacroTagParser.cs:line 194 at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.RenderRteMacros(String source, Boolean preview) in D:\a\1\s\src\Umbraco.Web\PropertyEditors\ValueConverters\RteMacroRenderingValueConverter.cs:line 59 at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.Convert(Object source, Boolean preview) in D:\a\1\s\src\Umbraco.Web\PropertyEditors\ValueConverters\RteMacroRenderingValueConverter.cs:line 96 at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, Object inter, Boolean preview) in D:\a\1\s\src\Umbraco.Web\PropertyEditors\ValueConverters\RteMacroRenderingValueConverter.cs:line 76 at Umbraco.Core.Models.PublishedContent.PublishedPropertyType.ConvertInterToObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, Object inter, Boolean preview) in D:\a\1\s\src\Umbraco.Core\Models\PublishedContent\PublishedPropertyType.cs:line 221 at Umbraco.Web.PublishedCache.NuCache.Property.GetValue(String culture, String segment) in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\Property.cs:line 211 at Umbraco.Web.PublishedPropertyExtension.Value[T](IPublishedProperty property, String culture, String segment, Fallback fallback, T defaultValue) in D:\a\1\s\src\Umbraco.Web\PublishedPropertyExtension.cs:line 39 at Umbraco.Web.PublishedContentExtensions.Value[T](IPublishedContent content, String alias, String culture, String segment, Fallback fallback, T defaultValue) in D:\a\1\s\src\Umbraco.Web\PublishedContentExtensions.cs:line 169 at Umbraco.Web.PublishedModels.BaseWithContent.getContent() in C:\Workspace\People Hub\PeopleHub\AppData\Models\BaseWithContent.generated.cs:line 52is working on a reply...