I am building a page template and in my pipeline first template is 'Extract components from page' which is out of the box template. After execution I see following package output.

Tridion/Component[] components somexml
Tridion/Component   component  component detail (Schema type is "Red")
Tridion/Component   component  component detail (Schema type is "Green")
Tridion/Page        page       page      detail detail

Page is my current page and I have 2 component presentations added to that.

Next in pipeline is my custom TBB that executes following line :

var item = package.GetByName( "Component" );
var component = engine.GetObject( item ) as Component;
if(component.Schema.Title == "Red"){I don't want to process this component and want to get next component.;}

item variable will contain the reference to the last component in the package output. both component have different schema.

My question is, after some processing if I find the component referenced to item variable is not the component I want, Can I get reference to next component? for example if component schema is "Red" I want to get next component.

  • 1
    Yes you can. Share your code and where you're stuck, and we can help with the details. Feb 24, 2014 at 2:27
  • question updated with a bit more detail. If schema is red then I want to get next component to check its schema type.
    – Ali
    Feb 24, 2014 at 2:33

2 Answers 2


Though your requirement is not fully clear to me. The below options could help.

  1. As you are using the TBB 'Extract components from page', The package will contain the array Components[] . so you can use it in your custom TBB to find component of your need.

  2. you can also iterate through component presentations, something like below

    foreach (ComponentPresentation cp in page.ComponentPresentations) {

    if (cp.Component.Schema.Title == "Red")


    // implement you logic for non-red components


  • components[] will give me id of component and template id, how can i get the schema information of that component? I tried to create new component object by id but that requires a 'session', don't know where will this session come from.
    – Ali
    Feb 24, 2014 at 6:35
  • 1
    First of all, you don’t need to create a New component, Just fetch the component from tridion using Engine object. As you written in the comment, You have “componentID” with you. Use this “componentID” to read the component from the Tridion. And then there is a property called “Schema”, which gives Schema information for the component. Code is given below to get the Schema Information (I am extracting Schema Title in code). Component com = (Component) engine.GetObject(componentID); Schema schm = com.Schema; string schemaTitle = schm.Title; Feb 24, 2014 at 8:01

It looks like you have more than one item called "Component" in your Package. Are you sure the default OOTB TBB is doing this?

One thing to keep in mind is that the Package is a Stack data structure (last-in-first-out), not a hash table as you might be thinking from the GetByName method. So when you peek an item in the stack (peeking is what GetByName does, not popping), you will get the reference to the top-most item by that name. If you want the next item, you first should pop the last one. This is done by removing an item off the Package with the package.Remove method. So keep peeking and popping till you find the item you want.

It also seems you have an array of Components as another item. If your components are also part of this array, then you can simply traverse it to find the item you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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