Getting published content in code when there are fields with macros
I have a custom AJAX service that returns a list of items by using TypedContentAtRoot and selecting the custom result objects.
This works fine unless there are macros in any of the text fields, in which case I get Cannot render a macro when there is no current PublishedContentRequest
I actually don't need the macros to run here, so I'd be happy with a solution that didn't bother running them and just returned the comment markup OR one that actually ran them.
My code is:
UmbracoHelper uhelper = new UmbracoHelper(UmbracoContext.Current);
var res = uhelper
.TypedContentAtRoot().First()
.DescendantsOrSelf()
.Where(x => x.DocumentTypeAlias == "Event")
.OrderBy(x => x.GetPropertyValue<MyApp.EventDates>("eventDates").EventDate)
.Select(x => new MyAppEventDetails(x));
Getting published content in code when there are fields with macros
I have a custom AJAX service that returns a list of items by using TypedContentAtRoot and selecting the custom result objects.
This works fine unless there are macros in any of the text fields, in which case I get
Cannot render a macro when there is no current PublishedContentRequest
I actually don't need the macros to run here, so I'd be happy with a solution that didn't bother running them and just returned the comment markup OR one that actually ran them.
My code is:
The property values are retrieved using e.g.
I see there are overloads
GetPropertyValue
for recursing, but not for disabling macro expansion.is working on a reply...