More in this section

Forums / Bugs & Issues / PageData GetRelatedItems giving item not found error

PageData GetRelatedItems giving item not found error

1 posts, 0 answered
  1. Steve
    Steve avatar
    3 posts
    12 Jun 2012
    30 Sep 2014
    Link to this post

    I've having a problem when calling GetRelatedItems<Image>("fieldname") on a PageData variable. For the page in question, I'm sure that the related item is there, but it was never found. This related item is a custom field for all pages.

    So I turned it around and retrieved the image id from the ContentLinksManager:

    ContentLinksManager contentLinksManager = ContentLinksManager.GetManager();
    LibrariesManager librariesManager = LibrariesManager.GetManager();
    var imageId = contentLinksManager.GetContentLinks( )
      .Where( l => l.ParentItemId == parent.NavigationNodeId )
      .Select( x => x.Id)

     'parent' it the above snippet is a PageData variable. This returns the Guid of the image. Then I call:

    Image imageItem = librariesManager.GetImage( imageId );

    I'm getting a Telerik.Sitefinity.SitefinityExceptions.ItemNotFoundException at this point.

    The strange part is that if I get the same page, but use the PageNode type, the related item is retrieved normally. As in here, where 'page' is a PageNode variable:

    var imageItem  = page.GetRelatedItems<Image>( "LandingPageMenu")

1 posts, 0 answered