IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
public
static
IQueryable<MediaContent> GetAncestorItems()
{
//gets an isntance of the LibrariesManager
var manager = LibrariesManager.GetManager();
//creates an image album
var imagesAlbum = manager.CreateAlbum();
imagesAlbum.Title =
"ImageAlbumTitle1"
;
manager.SaveChanges();
//creates a folder under the album
var folder = manager.CreateFolder(imagesAlbum);
var folderId = folder.Id;
folder.Title =
"FolderTitle"
//creates an image in the album and assigns the folder to the image
//by using the FolderId property
var image = manager.CreateImage();
image.Title =
"imageTitle"
image.FolderId = folderId;
//creates another folder under the album
var folder1 = manager.CreateFolder(imagesAlbum);
folder1.Title =
"ChildFolderTitle1"
//changes the folder of the image
manager.ChangeItemFolder(image, folder1);
//gets all the ancestors of the album
var ancestors = manager.GetAncestorItems(imagesAlbum);
return
ancestors;
}
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important