Copied to clipboard

Flag this post as spam?

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


  • Bex 444 posts 555 karma points
    Mar 14, 2011 @ 15:16
    Bex
    0

    How do I tell if a document type is in recycle bin?

    Hi

    I have a problem, I am calling back all documents with  a particular document type using the following code:

      DocumentType dt = DocumentType.GetByAlias("CiderMakerCountry");
                Content[] ciderMakerCountries = Document.getContentOfContentType(dt);

    This works fine and rings back ALL documents, unfortunately is also appears to bring back those in the recycle bin.

    Due to an error with umbraco I cannot delete anything out of the recycle bin.

    So my question is, how do I tell if a document type is in the recycle bin in code?

    Thanks

    Bex

     

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Mar 14, 2011 @ 15:23
    Dirk De Grave
    0

    Bex,

    Check the path of your content, if it starts with -20, than it's a document which resides in the recycle bin.

     

    Cheers,

    /Dirk

  • Hendy Racher 861 posts 3844 karma points MVP 2x admin c-trib
    Mar 14, 2011 @ 15:30
    Hendy Racher
    0

    Hi,

    Not sure which in version of Umbraco it was added, but there's also a .IsTrashed property on the Document object.

    DocumentType dt = DocumentType.GetByAlias("CiderMakerCountry");
    Content[] ciderMakerCountries = Document.getContentOfContentType(dt).Where(x => x.IsTrashed == false).ToArray();

    (wasn't there a .Smells property once or am I imagining that ?)

    HTH,

    Hendy

  • Bex 444 posts 555 karma points
    Mar 14, 2011 @ 15:31
    Bex
    0

    The path came back as "-1,-20,1427" but as now I know what I'm looking for I can see that the parentID = -20 so I can use that!

    Thanks loads! :)

  • Bex 444 posts 555 karma points
    Mar 14, 2011 @ 15:34
    Bex
    0

    Actually the isTrashed is available here! that's much easier! :) thanks Hendy!

  • 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.

Please Sign in or register to post replies