I'm giving LeBlender a quick try as it sounds like a really useful project. However, I've run in to a problem when trying to render my view.
I've created a grid editor 'LeBlender Accordion' through LeBlender and set up a view in the ~/Views/Partials/Grid/Editors directory called LeBlenderAccordion.cshtml.
I've then used the accordion on a grid page which seems to work okay, the page tries to output my view and does hit it correctly. It's throwing the following error however:
The model item passed into the dictionary is of type 'Lecoati.LeBlender.Extension.Models.LeBlenderModel', but this dictionary requires a model item of type 'Umbraco.Web.Models.RenderModel'.
It was a while a go since I posted this and unfortunately, I had to move ahead without LeBlender. Which of course means that I can't post much in the way of configs etc.
Hopefully someone else with the same issue will be able to help out in that respect.
{
"name": "PaddedLinkBox",
"alias": "PaddedLinkBox",
"view": "/App_Plugins/LeBlender/editors/leblendereditor/LeBlendereditor.html",
"icon": "icon-out",
"render": "/App_Plugins/LeBlender/editors/leblendereditor/views/Base.cshtml",
"config": {
"editors": [
{
"name": "Title",
"alias": "title",
"propretyType": {},
"dataType": "0cc0eba1-9960-42c9-bf9b-60e150b429ae",
"description": "Title of the link box."
},
{
"name": "Description",
"alias": "description",
"propretyType": {},
"dataType": "c6bac0dd-4ab9-45b1-8e30-e4b619ee5da3",
"description": "Description text for the linkbox."
},
{
"name": "Link To",
"alias": "linkTo",
"propretyType": {},
"dataType": "a6857c73-d6e9-480c-b6e6-f15f6ad11125",
"description": "Where the link box should go to."
},
{
"name": "Photo",
"alias": "photo",
"propretyType": {},
"dataType": "93929b9a-93a2-4e2a-b239-d99334440a59",
"description": "Background photo for the link box."
}
],
"frontView": ""
}
},
It seems like it is throwing an exception somewhere in the controller method when it is called in LeBlender.cshtml:
@(Html.Action("RenderEditor", "LeBlender", new { editorAlias = ViewData["editorAlias"], frontView = ViewData["frontView"], model = Model }))
I bypassed controller in the Base.cshtml and just called the partial view directly and it started to render correctly confirming at least the exception is being thrown there for some reason.
else
{
string viewName = string.IsNullOrEmpty(frontView) ? frontView = string.Format("/views/partials/grid/editors/{0}.cshtml", Model.editor.alias)
: frontView = string.Format("/Views/Partials/Grid/Editors/{0}.cshtml", frontView);
<text>
@*
Commented out because the controller is breaking something
@Html.Partial("/App_Plugins/LeBlender/editors/leblendereditor/views/LeBlender.cshtml", blenderModel, datas)
*@
@Html.Partial(viewName, blenderModel)
</text>
}
As said in the original post - I think the issue would be solved by by returning PartialView() rather than View() from the controller.
As to why this is an issue I don't know - related to the view inheritance I imagine from the error message, but I don't know why some would see this and not others.
The correct return from the controller in question is PartialView and not View() anyway as it is only ever called as a child action so its worth trying.
Hmmm...... thinking about this some more it may well be related to the _viewStart.cshtml file.
If the Layout declaration points to a file with @inherits Umbraco.Web.Mvc.UmbracoTemplatePage in it then the error will be getting thrown from the layout page rather than the the partial view.
By default Umbraco doesn't have a _viewstart which accounts for not being able to replicate the issue, Alex - do you have a _viewStart.cshtml file in you install, and does removing it fix the problem?
I just tried Timo's suggestion and it worked. Adding
@{
Layout = "";
}
to the grid partials that you create did the trick.
There's also a pull request on the GitHub project that added the layout fix to the examples as well. Returning a partial view might be the permanent fix for this though...
Not sure if the leBlender team are active any more though to be honest as the repo hasn't been updated n 3 months and the Umbraco core is a few versions behind in the repo.
Umbraco 7.2.8 Compatibility
I'm giving LeBlender a quick try as it sounds like a really useful project. However, I've run in to a problem when trying to render my view.
I've created a grid editor 'LeBlender Accordion' through LeBlender and set up a view in the
~/Views/Partials/Grid/Editors
directory calledLeBlenderAccordion.cshtml
.I've then used the accordion on a grid page which seems to work okay, the page tries to output my view and does hit it correctly. It's throwing the following error however:
My view looks like this:
We wondered if this may be a compatibility issue with the latest Umbraco - we're using 7.2.8?
My colleague also wondered if instead of using 'return View' (https://github.com/Lecoati/LeBlender/blob/master/Src/Lecoati.LeBlender.Extension/Controllers/LeBlenderController.cs#L77) you should be returning a PartialView?
We replicated a similar issue on another project (without LeBlender) and using PartialView seemed to get around this error.
Any help/suggestions would be great!
Also seeing this issue in 7.3
I'm also seeing this issue in 7.2.6
Has anyone found a fix for this?
Hi everyone,
We've done something similar to what you appear to be doing, however we didn't get this issue.
Our view has the same inherits statement, could you share what your config looks like for the editor for comparison please.
Nik
Hi Nik,
It was a while a go since I posted this and unfortunately, I had to move ahead without LeBlender. Which of course means that I can't post much in the way of configs etc.
Hopefully someone else with the same issue will be able to help out in that respect.
Here is what the config looks like:
It seems like it is throwing an exception somewhere in the controller method when it is called in LeBlender.cshtml:
I bypassed controller in the Base.cshtml and just called the partial view directly and it started to render correctly confirming at least the exception is being thrown there for some reason.
As said in the original post - I think the issue would be solved by by returning PartialView() rather than View() from the controller.
As to why this is an issue I don't know - related to the view inheritance I imagine from the error message, but I don't know why some would see this and not others.
The correct return from the controller in question is PartialView and not View() anyway as it is only ever called as a child action so its worth trying.
Thanks
Carl
Hmmm...... thinking about this some more it may well be related to the _viewStart.cshtml file.
If the Layout declaration points to a file with @inherits Umbraco.Web.Mvc.UmbracoTemplatePage in it then the error will be getting thrown from the layout page rather than the the partial view.
By default Umbraco doesn't have a _viewstart which accounts for not being able to replicate the issue, Alex - do you have a _viewStart.cshtml file in you install, and does removing it fix the problem?
Thanks
Carl
This fixed the issue for me (for now):
@{ Layout = null; }
I do have a _viewStart.cshtml in my project.
I just tried Timo's suggestion and it worked. Adding
to the grid partials that you create did the trick.
There's also a pull request on the GitHub project that added the layout fix to the examples as well. Returning a partial view might be the permanent fix for this though...
This will also fix the problem short term.
However as the controller action is only ever called as a child the correct fix is to return PartialView() rather than View().
It also means you don't have to repeat the code in every view just to override the _viewStart file.
Thanks
Carl
Pull request created for this
https://github.com/Lecoati/LeBlender/pull/18
Not sure if the leBlender team are active any more though to be honest as the repo hasn't been updated n 3 months and the Umbraco core is a few versions behind in the repo.
Thanks
Thanks Carl
I have merged your Pull request, the team is active but doesn't have too much time recently. Anyway, we will try to release a new versiĆ³n soon.
is working on a reply...