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.
@if(Model.Content.HasValue("contentPicker"))
{
var test = Model.Content.GetPropertyValue<IPublishedContent>("contentPicker");
@test.Name
}
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!
Deleted picked items in pickers
Hi all!
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.
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)
Thanks!
//Johannes
Hi Johannes,
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.
https://our.umbraco.com/packages/backoffice-extensions/nexu/
Dave
Hi Dave!
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!
//Johannes
Hi Johannes,
Normally the propertyvalue converter for the content picker should hanlde this.
So if you do
It should only return published items
https://github.com/umbraco/Umbraco-CMS/blob/v7/dev/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerPropertyConverter.cs
What type are using for the content picker ? I assume it is the built in content picker.
Dave
I thought that
HasValue("contentPicker")
was the best way to go but after some tinkering I came up with this: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!
// Johannes
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.