5
votes

Quick question. I'm building a Template Building Block (TBB) that retrieves metadata schema values from the parent folder of components. For example, all of the components listed in this folder will share the same title, but have different content. So, I created a schema and attached it to the parent folder. This way, if I want to change the title of all my components, all I have to do is change the metadata value on the folder.

I have this working with the parent folder TCM hard-coded, but, I need to grab this dynamically. Does anyone know how to grab the parent folder's TCM?

Thank you for your assistance.

1
"all of the components listed in this folder will share the same title" The title of each Component must be unique within its Folder, so that sounds unlikely. A common usage is to prefix similar components with the common part of the title, e.g. "Product A - Description", "Product A - Specification", etc. - Frank van Puffelen
Since you're mentioning a TBB, I'd guess "title" means some markup in a component presentation? - Alvin Reyes

1 Answers

7
votes

RepositoryLocalObjects all have a ".OrganizationalItem" property that will return the container for the object.

Something along these lines should get you started:

Component component = (Component)engine.GetObject(package.GetByName(Package.ComponentName));
Folder parent = (Folder)component.OrganizationalItem;
ItemFields folderFields = new ItemFields(parent.Metadata, parent.MetadataSchema);