Copied to clipboard

Flag this post as spam?

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


  • Alex 21 posts 41 karma points
    Aug 16, 2010 @ 12:42
    Alex
    0

    Content.getContentOfContentType method returning deleted content

    I have deleted a content node in the CMS but the method Content.getContentOfContentType is still returning the deleted content item. My code is as follows:

    try

    {

        contentType = ContentType.GetByAlias("Affiliate");

    }

    catch (ArgumentException ex)

    {

        // the content type isn't set up, so fail silently

        return;

    }

     

    // get all affiates

    affiliates = Content.getContentOfContentType(contentType);

     

    // find affiliate by code

    foreach (Content affiliate in affiliates)

    {

    // working with content here...

    }

  • Sascha Wolter 615 posts 1101 karma points
    Aug 16, 2010 @ 14:10
    Sascha Wolter
    0

    Hi Alex,

    have you enabled caching for the usercontrol that contains the code above? Try recycling your app pool if you have access to it to see if caching is the issue here.

    Sascha

  • Alex 21 posts 41 karma points
    Aug 16, 2010 @ 15:30
    Alex
    0

    Thanks for the quick response Sascha. Unfortunately this piece of code is part of an .NET HTTP response filter, so I don't think there's any caching going on. I think either the content isn't getting deleted properly via the CMS, or perhaps the getContentOfContentType method isn't the right API method to use?

  • Sascha Wolter 615 posts 1101 karma points
    Aug 16, 2010 @ 16:11
    Sascha Wolter
    0

    Hm, not really sure on the Content.getContentOfContentType call, have personally never used it although that certainly doesn't say anything. It would be very helpful to know if it gets the information from the xml cache or directly from the database.

    Alternatives to try out with the assumption that 1234 is the id of the parent node of all affiliates:

    Node affiliateParent = new Node(1234);
    foreach(Node affiliate in affiliateParent.Children){
      //optionally check if the affiliate is of node type 'Affiliate'
      //do something with the affiliate node
    }

    or

    Document affiliateParent = new Document(1234);
    foreach(Document affiliate in affiliateParent.Children){
      //...
    }

    The first version will just work on the xml cache whereas the second one will actually allow you to get down to the database level. So for your purposes the first version would be the preferred one, if you still get this issue it might be an idea to just give the second one a go.

    Hope any of that works,
    Sascha

     

     

Please Sign in or register to post replies

Write your reply to:

Draft