Incorrect number of listitems returned
I am using the API to access a list and album. I bring back all of the items and the number seems to always be incorrect.
For instance, I have a list with 5 list items in it. The API is returning 11. I have an album with 2 images in it. The API is returning 5 images.
Any thoughts on why this would be happening? I frequently did this in SF 3.x with no problems.
Below is some commented code.
private void BuildUpcomingTrips() var list = GetListByName("Upcoming Trips List"); //list.ListItems returns 11 items, but there are only 5 items in this list foreach (var listItem in list.ListItems) items.Append(listItem.Content)); private void BuildSlideshow() var album = GetAlbumByName("Homepage Slideshow Images"); //album.Images.ToList() returns 5 items, but there are only 2 items in this list foreach (var image in album.Images.ToList()) items.Append(simage.UrlName)); private static Telerik.Sitefinity.Libraries.Model.Album GetAlbumByName(string name) var librariesManager = LibrariesManager.GetManager(); var albums = librariesManager.GetAlbums(); return Enumerable.FirstOrDefault(albums, album => album.Title.ToLower() == name.ToLower());private static Telerik.Sitefinity.Lists.Model.List GetListByName(string name) var listManager = new Telerik.Sitefinity.Modules.Lists.ListsManager(); var lists = listManager.GetLists(); return Enumerable.FirstOrDefault(lists, list => list.Title.ToLower() == name.ToLower());Even stranger. Without doing anything, now the album shows 4 items (not five).
Hi Solomon,
Can you try getting only the items with status live? cnt.Status == ContentLifecycleStatus.Live. I suppose that you are returning all items and this is why there are difference in the items count.
Best wishes,
Ivan Dimitrov
the Telerik team
That was it. Thanks, Ivan!
I modified my code and everything is right in the world.
private void BuildSlideshow() var album = GetAlbumByName("Homepage Slideshow Images"); foreach (var image in album.Images.ToList().Where(image => image.Status == ContentLifecycleStatus.Live)) items.Append(image.UrlName));