I need to get parent component from an ambed compoment Multimedia from 3 or 4 levels until get the page who contains the parent component in Tridion 2011.

I see these methods:



But It returns the child´s from my component. I have this method but I only get the children component.

private Component GetParentComponent(Component component)
        UsedItemsFilter usedItemFilter = new UsedItemsFilter(component.Session)
            IncludeBlueprintParentItem = true,
            ItemTypes = new Tridion.ContentManager.ItemType[] { ItemType.Component },
            BaseColumns = ListBaseColumns.Id
        IEnumerable<IdentifiableObject> usedItems = component.GetUsedItems(usedItemFilter);
        if (usedItems == null) return null;
        usedItems = usedItems.Where(usedItem => usedItem.Id.ItemId.Equals(component.Id.ItemId));
        if (usedItems == null) return null;
        return usedItems.FirstOrDefault() as Component;

Can you guys help me?

enter image description here


  • I'm sorry Victor but I can't see the scenario cleary. Can you explain, or give an example of what you need? May 12, 2016 at 7:51

2 Answers 2


To see the parent components of a certain component you need to use the


as it gives you the components that use that component. The method that you post GetParentComponent(Component component) gives the child components as it uses the UsedItemsFilter instead of the UsingItems one.

With this C# Fragment you can get what you want, but the problem I see is that the component may be included in various components or pages. In this code I'm only considering the first result.

<%@Import Namespace="System.Collections.Generic" %>

// fragment to obtain parent page from a component
private string GetParentRecursive(string uri)
  Session ses = engine.GetSession();
  VersionedItem vItem = (VersionedItem)engine.GetObject(uri);

log.Debug("vItem " +vItem.ToString());
UsingItemsFilter usingItemFilter = new UsingItemsFilter(ses)
  IncludeLocalCopies = true,
  ItemTypes = new[] {ItemType.Page, ItemType.Component}
// may be a List (not only one)
// processing the first result
foreach (VersionedItem it in vItem.GetUsingItems(usingItemFilter))
  if (it.Id.ItemType == ItemType.Component){
    return GetParentRecursive(it.Id.ToString());
  } else if (it.Id.ItemType == ItemType.Page){
    return it.Id.ToString();

return "not found";

// include your own component Uri
string idFirstComp = "tcm:x-yy**strong text**";
  • I need this to TOM.NET API, since a CPT, I recibe the components from a component include in a page through a category and I recibe a component child (document) but when I get the child component I need to go up levels until get the principal component include in a page (and the page). I need to implement this with TOM.Net. Thanks for the answer. Regards
    – Victor R
    May 12, 2016 at 7:06
  • Can you see the img? I try explain my problem to get the components and Pages. Regards
    – Victor R
    May 12, 2016 at 8:54
  • I have included a C# fragment in the answer that gives you the parent page of a component included in other components in a recursive way. Hope that it helps. May 17, 2016 at 15:19

I have MyDoc but I need to get the Page which contains my doc component

It seems that you're trying to Resolve items in this TBB, i.e. determine which items would be published if you were to publish a given item. You can do that in a TBB, though I think additional clarity on the actual requirement (rather than the solution) would probably get you a better answer because I'm struggling to see why you would want to!

You can call the Resolver with a ResolveEngine.ResolveItem(), which requires:

  • An Item to Resolve
  • An Instruction on how to handle the resolving
  • A Publish Context (which requires a Publication Target)

For the Publication Target, there will be one in actual publishing, but not in Template Builder, so you'll have to choose one that the publication can actually publish to.

class GetPagesUsingComponent : ITemplate
    public void Transform(Engine engine, Package package)
        string id = "tcm:24-8238"; //Note hardcoded TCM Id
        Component component = (Component) engine.GetObject(id);
        PublicationTarget publicationTarget = engine.PublishingContext.PublicationTarget;
        if (publicationTarget == null) //If it's Template Builder, this will be null, so...
            publicationTarget = (PublicationTarget)engine.GetObject("tcm:0-5-65537");
            //again, note hardcoded TCM Id - which should be a publication target the
            //publication can use!

        ResolveInstruction resolveInstruction = new ResolveInstruction(engine.GetSession())
            IncludeChildPublications = true,
            StructureResolveOption = StructureResolveOption.OnlyItems

        PublishContext publishContext = new PublishContext(

        List<ResolvedItem> resolvedItems = ResolveEngine.ResolveItem(component,
            .Where(resolvedItem => resolvedItem.Item.Id.ItemType == ItemType.Page)

        TemplatingLogger.GetLogger(this.GetType()).Debug("Found " + resolvedItems.Count);
        foreach (ResolvedItem resolvedItem in resolvedItems)
                resolvedItem.Item.Id + " - " + resolvedItem.Item.Title);

On our system, this outputs into the Debug log in Template Builder:

GetPagesUsingComponent: Found 2
GetPagesUsingComponent: tcm:24-8244-64 - Business travel
GetPagesUsingComponent: tcm:24-13433-64 - Business travel policy

Just to reiterate my first point: just because you can do this doesn't mean you necessarily should. Resolving is a fairly intensive database call that is run whenever something is published, and by calling it again it's being run twice. There is probably a better solution to your requirement if you could post what you're trying to achieve instead of your anticipated solution :)

  • I don´t need that. Thanks very much. But I need Get component who contains my actual component and so on, until get page who contains my componente and all of components. This is the structure, since I have "My Component", I need get "Another Component" and "Component Embed" and "Page". I just get My Component but I need get the others. [Page [Component Embed [Another Component [My Component] ] ] ]
    – Victor R
    May 17, 2016 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.