I've been having issues with this plugin on several Umbraco 7.1.x installations(a 7.1.6 and a 7.1.8 I believe). The backoffice parts of the plugin work splendidly, but I get a NullReferenceException when I try to view a page. I've set a min & max items of 2 & 3 respectively on my data type. Here's a copy of my template (it's just a clone of the front page example)
I must say that I havenĀ“t try out this package myself, but I would try to help you the best I can.
What I think you are missing is that you need to tell what type of data are gettig back, from the package page example I see that you are missing the <YouTube> after GetPropertyValue
I have a look on your code once again. I think I spotted what give you the error.
Try to change:
@inheritsUmbraco.Web.Mvc.UmbracoTemplatePage
To this line:
@inherits UmbracoTemplatePage
I have also add a check to check if the property has a value on the current page, if not, then it will not print out, this is a good thing to do if you have e.g a unorded list, or some other HTML around that you only want to print if the field contains a value.
I figured out the problem using your advice. The string in the foreach statement needs to be the name of the document property (in my case "YouTube") not "video". I used the following template and kept changing things until I triggered the if statement (it also works with you inherits line change).
<h2>Precondition test string</h2> @if(Model.Content.HasValue("YouTube")){ <h2>If statement triggered</h2> }
So now that I'm getting return values from Model, I should be able to run the foreach. I updated my old template, and I got a few videos to display on my page!
Null Reference Exception on simple implementation
Hi there,
I've been having issues with this plugin on several Umbraco 7.1.x installations(a 7.1.6 and a 7.1.8 I believe). The backoffice parts of the plugin work splendidly, but I get a NullReferenceException when I try to view a page. I've set a min & max items of 2 & 3 respectively on my data type. Here's a copy of my template (it's just a clone of the front page example)
The error occurs on the @foreach line and prints the following stack trace.
edit: I installed plugin version 1.0.2 build 65. Added new stack trace.
Hi Alex and welcome to our.
I must say that I havenĀ“t try out this package myself, but I would try to help you the best I can.
What I think you are missing is that you need to tell what type of data are gettig back, from the package page example I see that you are missing the <YouTube> after GetPropertyValue
So try this:
Hope this helps,
/Dennis
Thank you for the kind welcome and help!
That's strange, I thought the return type was there. I fixed that but I'm still having the issue. Here's my new stack trace.
Hi Alex,
I have a look on your code once again. I think I spotted what give you the error.
Try to change:
To this line:
I have also add a check to check if the property has a value on the current page, if not, then it will not print out, this is a good thing to do if you have e.g a unorded list, or some other HTML around that you only want to print if the field contains a value.
Hope this helps,
/Dennis
Hi Dennis,
I figured out the problem using your advice. The string in the foreach statement needs to be the name of the document property (in my case "YouTube") not "video". I used the following template and kept changing things until I triggered the if statement (it also works with you inherits line change).
So now that I'm getting return values from Model, I should be able to run the foreach. I updated my old template, and I got a few videos to display on my page!
Thank you so much for your help!
is working on a reply...