If you go into admin mode and choose set access rights you can navigate to the global library and all your block folders. Point on a folder name you will see the id in the url.
Thanks for your response Peter. But i don't want to bind to an id which might change as we go through environments. Can I pick it up programmatically by the folder name? A folder search type function - i'm struggling to find the part of the API that would allow me to do that.
Many Thanks
You can read the folders like any other content. If you know that your folder is below the root folder and now the name you could do something like this.
IEnumerable<IContent> blockFolders = contentrepository.GetChildren<IContent>(ContentReference.GlobalBlockFolder);
ContentReference blockStartNode = null;
foreach (var f in blockFolders)
{
if (f.Name.ToLower().Contains(blockfoldername))
blockStartNode = f.ContentLink;
}
A bettor solution would maybe be to build a editordescripopr and selectfactory class so you can make a nice dropdown on the starpage maybe where the system admin or editor can choose which block folder to use.
Hi all
How would I access a folder in the blocks file system area i,e, for a shared block.I am programmatically creating blocks but at the moment I can only put them in the root i.e.
ProductBlock productBlock = contentRepository.GetDefault<ProductBlock>(ContentReference.GlobalBlockFolder);
So i would like to get a reference to another folder for this call
Many Thanks for any all help