I have CMS + Commerce site. And the CMS part is working fine and i started adding some catalog items and try to render it. BUt get the error.
i have a simple catalog item
GUID = "ff325833-bf93-449f-bd80-4f138fc92c5d",
MetaClassName = "Tipping Category",
DisplayName = "Tipping Category",
Description = "Display this Tipping category products.")]
[AvailableContentTypes(Include = new
public class TippingCategory : NodeContent
I have a simple controller to render some content of this NodeContent.
public class TippingCategoryController : ContentController
public ActionResult Index(TippingCategory currentContent)
And i have a simple view in ~\Views\TippingCategory\index.cshtml
But when rendering the catalog item (via catalog url) i get the following error:
The model item passed into the dictionary is of type 'Castle.Proxies.TippingCategoryProxy', but this dictionary requires a model item of type 'Hyva.Web.Implementation.ViewModels.IPageViewModel`1[Hyva.Web.Models.Pages.BasePageData]
I think this is because i have my _viewstart.cshtml which has the layout to my _layout.cshtml and that has as a model the IPageViewModel which is my standard for CMS pages. So now i cannot combine these 2?
I read this post: https://ejooeun.com/2015/09/25/the-model-item-passed-into-the-dictionary-is-of-type-castle-proxies-myvariationproxy-but-this-dictionary-requires-a-model-item-of-type-episerversite-models-viewmodels-ipageviewmodel1episerver/ but i did it correctly.
What am i missing?
Not sure if you had a copy and paste error in your post, but your controller should have been this:
public class TippingCategoryController : ContentController<TippingCategory>
Oww.. the editor stripped it out... I changed it in the first post. It was like you said. So thats correct.
Btw.. i'm on the latest Commerce en CMS packages.
What else am i missing?
What is in your view then?
My view is like my first post says.. just a simple text (TEST) in a paragraph to see that it works.
And my correct Model which it uses.
"I think this is because i have my _viewstart.cshtml which has the layout to my _layout.cshtml and that has as a model the IPageViewModel which is my standard for CMS pages. So now i cannot combine these 2? "
This is true (and I missed it). You can only have one content in a view. One possible solution is to introduce a ViewModel that contains your page data and your catalog content. In your Index action you would create that ViewModel from the currentContent and the page data and return
Both the view will take the ViewModel and then get the page data and catalog content as they need
I understand but if I check the quicksilver solution I don't see them doing this there. They have their _layout.Cshtml with another model and catalog content view with another model and they just glue together... And I haven't found a post where other have this problem, so I think in my case I'm missing something else ..
There is no model in _layout.cshtml in Quicksilver :)
Oh man ... now this mean i would have to refactor my whole CMS pages and everything to make this work together .... :-(
you know what is very confusing.. If you follow the concept of setting up your CMS using the Alloy demo(kit) with model in the _layout.cshtml, and now additionally you add the commerce part to it, then you have a problem. That's what i am facing now.
what would be the best approach to glue those 2 together without refactoring the whole CMS site (multilingual).