I'm having trouble with mntp2 and I wondered if you guys could give me a hand.
I have this code which works fine when enablepropertyvalueconverters is disabled but not enabled. I am working on a partial view which is used in templates.
Maybe you could try to publish the node again or restart the application.
I have had it happened that I need to restart the application for the values to be returned correctly.
Do you get an error or is there just nothing in the list ?
Object reference not set to an instance of an object. Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
Line 12: *@ Line 13: Line 14: @{ var selection =
Model.Content.GetPropertyValue<>
How are you calling the partial from the template ?
If you write out @Model.Content.GetPropertyValue("propertyField") does it say System.Collections.Generic.List`1[Umbraco.Core.Models.IPublishedContent] ?
Can you check if the Model.Content is null or actually the list ?
// this does not work due to passing variables and no content model
@Html.Partial("Boxes", new ViewDataDictionary { { "field", "columnRightBoxes" }, { "recursive", true } })
// this works due to NOT passing variables thus the content model is not overwritten
@Html.Partial("Boxes")
Can I pass the content model on and the variables as well?
Multi Node Tree Picker 2
Hi everybody,
Umbraco 7.12.3
I'm having trouble with mntp2 and I wondered if you guys could give me a hand.
I have this code which works fine when enablepropertyvalueconverters is disabled but not enabled. I am working on a partial view which is used in templates.
So how do I loop through mntp2
I tried with Model.Content.ColumnRightBoxes but got an null exception.
I can easily get it to work with content picker but not multi node content picker.
Thanks
Hi Scott,
Try this
Hi Garðar
I did look to the documentation but it does not work.
Basically I have created a document type with a mntp2 in it.
Then I have created a partial view which is called from a template.
Then I have created a page where I have selected in this case just one other page using the mntp2 but no luck.
Maybe you could try to publish the node again or restart the application. I have had it happened that I need to restart the application for the values to be returned correctly.
Do you get an error or is there just nothing in the list ?
Did that as well.
It works when pasted into the template file
Clarification:
What is in the documentation works when executed from the template but not from the partial view
I get this error:
And that is using the stock examples from Umbraco
Hmmm thats odd.
How are you calling the partial from the template ?
If you write out @Model.Content.GetPropertyValue("propertyField") does it say System.Collections.Generic.List`1[Umbraco.Core.Models.IPublishedContent] ?
Can you check if the Model.Content is null or actually the list ?
I actually just tried to call it differently
// this does not work due to passing variables and no content model @Html.Partial("Boxes", new ViewDataDictionary { { "field", "columnRightBoxes" }, { "recursive", true } })
// this works due to NOT passing variables thus the content model is not overwritten @Html.Partial("Boxes")
Can I pass the content model on and the variables as well?
I changed it to:
@Html.Partial("Boxes", Model.Content, new ViewDataDictionary { { "field", "columnRightBoxes" }, { "recursive", true } })
Now I'll change the script
By the way Garðar, thanks for pitching in!
is working on a reply...