November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi, this code may be helpfull it lists all images for a page. It shold be fairly easy to list folders instead.
public static IEnumerable<ImageFile> GetPageImages(PageData page)
{
IEnumerable<ImageFile> images = null;
if (page != null && page.ContentAssetsID != Guid.Empty)
{
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var contentAssetFolder = contentRepository.Get<ContentAssetFolder>(page.ContentAssetsID);
images = contentRepository.GetChildren<ImageFile>(contentAssetFolder.ContentLink);
}
return images;
}
Thanks for your reply Daniel. Question: I'm trying to read the folders by replacing <ImageFile> (which I had working earlier) with <ContentAssetFolder> but that gives an empty result. It should, in my case, return a list or IEnumerable containing 4 folders.
Code:
IEnumerable<ContentAssetFolder> folders = repo.GetChildren<ContentAssetFolder>(contentAssetFolder.ContentLink);
Any ideas?
Regards,
Patrik
Instead of ContentAssetFolder, what is returned when you do IContent instead?
Try debugging with this IEnumerable<IContent> folders = repo.GetChildren<IContent>(contentAssetFolder.ContentLink);
Just to see if you have the folders in some "dynamic array structure way", then try to extract the folders and casting them if necessary.
/Daniel
Hello Joshua and Daniel,
enumerating IContent works perfect. The exact cast is <ContentFolder>.
Thanks!
Hello
For a certain page, say the start page, i have N number of asset folders (Folder1, Folder2, Folder3 etc). Stored in these are documents related to each folder.
I need to list the documents per folder. How do I get handles or such for each folder, and then read it's contents? I've been messing around with ContentAssetHelper and GetAssetFolder() (ie I googled it without finding any good examples) but with absolutely no luck at all.
Any help greatly appreciated.
Kind regards,
Patrik