Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • yumin 51 posts 243 karma points
    Jun 18, 2013 @ 11:25
    yumin
    1

    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

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jun 18, 2013 @ 12:19
    Jeroen Breuer
    0

    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

  • yumin 51 posts 243 karma points
    Jun 19, 2013 @ 08:00
    yumin
    0

    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

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jun 19, 2013 @ 14:31
    Jeroen Breuer
    100

    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

  • yumin 51 posts 243 karma points
    Jun 26, 2013 @ 09:39
    yumin
    0

    thanks jeroen

Please Sign in or register to post replies

Write your reply to:

Draft