Selecting root level images of library

Posted by Community Admin on 04-Aug-2018 19:01

Selecting root level images of library

All Replies

Posted by Community Admin on 09-Sep-2013 00:00

I have a library called Slides that contains 5 images.  I then have a nested folder that contains 2 images.  I am looking for the best way to display only the 5 images when a user selects the Slides library via my widget designer.  Right now this is what I have that works, but I am guessing there is a better way.

if (this.AlbumId != Guid.Empty)
            
                model.AlbumId = this.AlbumId;
 
                var manager = LibrariesManager.GetManager();
                var album = manager.FindFolderById(model.AlbumId);
 
                if (album.GetType() == typeof(Telerik.Sitefinity.Libraries.Model.Album))
                
                    model.Images = ((Telerik.Sitefinity.Libraries.Model.Album)album).Images().Where(i => i.FolderId == null
                     && i.Status == ContentLifecycleStatus.Live);
                
                else
                
                    model.Images = manager.GetImages().Where(i => i.FolderId == album.Id && i.Status == ContentLifecycleStatus.Live);
                
            


By default just using the Images() extension method for Albums will return all images nested or not that belong to said library. (i.e. I was getting 7 back).

Posted by Community Admin on 12-Sep-2013 00:00

Hello Stacey,

 The approach you took is the correct one, because the difference between the top level library and the nested folders (libraries) is only that the top level library doesn't have a folderId.

Regards,
Jen Peleva
Telerik
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed