I have created a macro but get the following error:
Umbraco.Web.Mvc.ModelBindingException: Cannot bind source type Umbraco.Web.Models.PartialViewMacroModel to model type Umbraco.Core.Models.IPublishedContent.
Is it possible to render a view in a Rich Text Editor with a macro? I feel this is probably simple! Thank you in advance.
I found the answer after a few hours of trying everything! Firstly, it is important to note the reason for the error is because the partial view inherits one model and the macro has it's own so it was always going to clash.
To get around this I used the macro query builder. To use this you will need to create a marco partial and then on the top right the option will be available.
I then copied out the html from my partial and it worked successfully. Use GetPropertyValue() to render the actual content and not the default @item.Name as this just gives you the name of the item (handy if you are creating a list) but I wanted to render content within a RTE. To obtain the ID, select the info tab on the item you want to display. Here is the finished code:
How do you use a macro to display a partial view?
I would like to display a partial view in a rich text editor. The code in my partial view is:
I have created a macro but get the following error:
Umbraco.Web.Mvc.ModelBindingException: Cannot bind source type Umbraco.Web.Models.PartialViewMacroModel to model type Umbraco.Core.Models.IPublishedContent.
Is it possible to render a view in a Rich Text Editor with a macro? I feel this is probably simple! Thank you in advance.
I found the answer after a few hours of trying everything! Firstly, it is important to note the reason for the error is because the partial view inherits one model and the macro has it's own so it was always going to clash.
To get around this I used the macro query builder. To use this you will need to create a marco partial and then on the top right the option will be available.
I then copied out the html from my partial and it worked successfully. Use GetPropertyValue() to render the actual content and not the default @item.Name as this just gives you the name of the item (handy if you are creating a list) but I wanted to render content within a RTE. To obtain the ID, select the info tab on the item you want to display. Here is the finished code:
is working on a reply...