Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8901

Kentico 13 Core - Calling in Field From Parent View Model to Childview Model

$
0
0
I am trying to call in a field from a parent view model into a child view model. To get the hero image from the parent page to the child page. By itself, this method of calling in the hero image from the parent page to the child page works. However, I am running into issues because of using the Pages field type. We are using the Pages field to load related pages on the view. Again this method of calling in pages this way works.The issue is because I am calling in the parent hero on the child view model, the pages field is erroring our because I don't have a reference to the hero image.model.RelatedResources = resourceItem.Fields._RelatedResources.Select(p =@ ResourceItemViewModel.GetViewModel((ResourceItem)p, pageUrlRetriever, attachmentUrlRetriever));Error CS7036 There is no argument given that corresponds to the required formal parameter 'parentHero' of 'ResourceItemViewModel.GetViewModel(ResourceItem, IPageUrlRetriever, IPageAttachmentUrlRetriever, ResourcesExpand)'So my questions are: Is there a better way to call in a field on a parent view model to a child view model? I this is a good way to do this, how can I null out parentHero on the pages field so it's not trying to look for it everytime I use this:model.RelatedResources = resourceItem.Fields._RelatedResources.Select(p =@ ResourceItemViewModel.GetViewModel((ResourceItem)p, pageUrlRetriever, attachmentUrlRetriever));I am using this method to call in related resources on several different view models: model.RelatedResources = resourceItem.Fields._RelatedResources.Select(p =@ ResourceItemViewModel.GetViewModel((ResourceItem)p, pageUrlRetriever, attachmentUrlRetriever));Thanks for any help.See code below in the answer

Viewing all articles
Browse latest Browse all 8901

Trending Articles