I don't know which version you are on, but in 6.0.6 or 6.1.1 you can use IPublishedContent by using Umbraco.TypedConent(id) and if the node doesn't exist it will return null.
Sorry I don't know if there is method which checks if a node is deleted. You could try to write a custom query which checks the umbracoNode table in the database to see if it's there.
Even in webforms you can use IPublishedContent. If you're in a UserControl you can let it inherit from Umbraco.Web.UmbracoUserControl so you have the UmbracoHelper available and you can do something like Umbraco.TypedContent(id). Maybe a simple check if Umbraco.TypedContent(id) == null and Umbraco.TypedMedia(id) == null is also good enough?
determine if a node or media is removed via the API
use content id
Node node = new Node(content id is removed);
node is not null, I determine if a node is removed via node's id == 0
but if this code use media id
Node node = new Node(media id);
no matter whether the media is removed, node's id always 0
so how to determine whether the node(no matter content or media) is removed from api or any other better way?
Thanks in advance
I don't know which version you are on, but in 6.0.6 or 6.1.1 you can use IPublishedContent by using Umbraco.TypedConent(id) and if the node doesn't exist it will return null.
More info here: http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx - http://our.umbraco.org/documentation/Reference/Mvc/querying
Jeroen
thank Jeroen, my umbraco ver is 6.1.1, and used webform not mvc , I thought you might not know what I mean.
I would like to know if umbraco have a method can determine whether the node is deleted, no matter the node is content or media.
using Umbraco.TypedConent(id) and if the node doesn't exist it will return null. I agree , but the id could be a media id.
using Umbraco.TypedMedia(id) and if the node doesn't exist it will return null. so may be if umbraco have a method can determine whether the
id is content or media will be easy to solve this problem.
Jeroen, wait for you reply, thanks
Hello,
Sorry I don't know if there is method which checks if a node is deleted. You could try to write a custom query which checks the umbracoNode table in the database to see if it's there.
Even in webforms you can use IPublishedContent. If you're in a UserControl you can let it inherit from Umbraco.Web.UmbracoUserControl so you have the UmbracoHelper available and you can do something like Umbraco.TypedContent(id). Maybe a simple check if Umbraco.TypedContent(id) == null and Umbraco.TypedMedia(id) == null is also good enough?
Jeroen
thanks jeroen
is working on a reply...