Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I just have to start by saying that I absolutly love Umbraco!
But this is the biggest issue that experience.
Let's say I have a content picker. I pick a node and then delete the picked node. I would get a "null" error even if I have this if statement.
var test = Model.Content.GetPropertyValue<IPublishedContent>("contentPicker");
The node is still picked but this shows in the backoffice
If you empty the recycle bin the node disapears from the picker but the "null" error is still ongoing. It's not until you "save and publish" the node again with nothing picked that the error stop occurring.
This is something that I experience quite often during development.
What I would like, is that the *node disappears from the pickereven if it's in the recycle bin and that the "null" error dissapears . * Is a nyone else experiencing this? Or dose anyone have an solution to this? or know how I could go about doing this myself?
(This is testen on Umbraco 7.14 with the default kit installed)
I always write defensive code to prevent errors during rendering when something is unpublished or deleted.
Another option is to install my Nexu package. This will keep track of internal links and will warn editors when they try to delete/unpublish a item that is in use in another content item.
I am a bit unsure on the term "defensive code". Do you mean that I could rewrite the if statement to not "break" even if the selected node is in the recycle bin? if so, how would that look?
I took a look at the plugin and it's really good! although it would be great if you were forced to unpick the node before you could delete it. And that you could unpick it from the "are you sure" modal. Is the project on github? would love to take a look at it myself!
Normally the propertyvalue converter for the content picker should hanlde this.
So if you do
It should only return published items
What type are using for the content picker ? I assume it is the built in content picker.
I thought that HasValue("contentPicker") was the best way to go but after some tinkering I came up with this:
var foo = Model.Content.GetPropertyValue<IPublishedContent>("contentPicker");
if(foo != null)
So time start using this instead of HasValue("contentPicker") ..
Thanks for everything Dave!
And if I may say, your plugin should be built in with Umbraco!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted