I am currently struggling with getting a specific custom field from an object in Sitefinity.
The object's custom field is of type Social media (OpenGraph), meaning it's an o-g meta data description property:
I tried these:
var test = _event.GetRelatedItems<DynamicContent>("OpenGraphDescription");
var test1 = _event.GetRelatedItems<IDataItem>("OpenGraphDescription");
But didn't work.
I am, however, able to get Image OG metadata doing:
var image = item.GetRelatedItems<Image>("OpenGraphImage").FirstOrDefault();
The only difference I see is that I'm getting that one converting it to an internal Sitefinity model (Image). So maybe I'm missing some model type..
I appreciate the help!
CodePudding user response:
FYI, the dynamic ItemViewModel is SO MUCH easier to work with than the default API.
@{
var itemVM = new ItemViewModel(yourDynamicItem);
}
<h1>@itemVM.Fields.OpenGraphDescription</h1>
You don't need to worry about the types because everything off Fields is dynamic

