title: Tridion: Component Template issue when looping over linked components
body: <p><strong>Hello,
  I got a problem with looping over my linked component.<br>
  I created a EmailSetup(View <a href="http://img9.imageshack.us/img9/8859/schemadesign.jpg" rel="nofollow">UML diagram</a>) Component with a product item.<br>
  The product Component has schema (EmailBlockWithCode).</strong><br>
  Product:<ul> <li>- Code = "wms_III"</li>
          <li>- Item:</li> <ul><li>- Key = "ProductKey"</li><li>- Content = "ProductContent"</li></ul>
           <li><ul> - CallToAction :</li> <li>- Item: <ul></li><li>- Key = "BluetoothKey"</li>
                                 <li>  - Content = "BluetoothContent"</li></ul></ul></ul></p>
  
  <p><strong>When i loop over this component with the code :</strong></p>
  
  <pre><code>  &lt;products&gt;
              &lt;!-- TemplateBeginRepeat name="Component.Fields.Product" --&gt;
              @@GetComponent(Field,'Product')@@
              &lt;product name="@@Product.Code@@"&gt;   
                &lt;!-- TemplateBeginRepeat name="Product.Fields.Item" --&gt;
                  &lt;@@Product.Fields.Item.Key@@&gt;&lt;![CDATA[@@Product.Fields.Item.Content@@]]&gt;&lt;/@@Product.Fields.Item.Key@@&gt;
                &lt;!-- TemplateEndRepeat --&gt;
                &lt;!-- TemplateBeginRepeat name="Product.Fields.CallToAction" --&gt;
                  @@GetComponent(Field,'CallToAction')@@
                  &lt;@@CallToAction.Fields.Item.Key@@&gt;&lt;![CDATA[@@CallToAction.Fields.Item.Content@@]]&gt;&lt;/@@CallToAction.Fields.Item.Key@@&gt;
                &lt;!-- TemplateEndRepeat --&gt;    
              &lt;/product&gt;
           &lt;!-- TemplateEndRepeat --&gt;
      &lt;/products&gt;
  </code></pre>
  
  <p><br>This is the function GetComponent<br></p>
  
  <pre><code>[TemplateCallable]
          public string GetComponent(string tcmUri, string packageVariable) {
              Assert.NotEmpty("tcmUri", tcmUri);
              Assert.NotEmpty("packageVariable", packageVariable);
              IdentifiableObject identifiableObject = m_Engine.GetObject(new TcmUri(tcmUri));
  
              if (identifiableObject as Component == null) {
                  throw new BuildingBlockException("Given tcmUri '" + tcmUri + "' is not a Component.");
              }
  
              Item previousItem = m_Package.GetByName(packageVariable);
              if (previousItem != null) {
                  m_Package.Remove(previousItem);
              }
              Component component = identifiableObject as Component;
              m_Package.PushItem(packageVariable, m_Package.CreateTridionItem(ContentType.Component, component));
              return "";
          }
  </code></pre>
  
  <p><strong>My output is :</strong></p>
  
  <pre><code>&lt;products&gt;
          &lt;product name="wms_III"&gt;    
  
          &lt;/product&gt;
      &lt;/products&gt;
  </code></pre>
  
  <p><strong>So my problem is that the code doesn't loop <br>over the 'item' (key = ProductKey; content = ProductContent)
  I have found a function IteratingOverMultivalueEmbeddedFields but this also won't loop my product. code:</strong></p>
  
  <pre><code>&lt;!-- TemplateBeginRepeat name="Component.Fields.Product" --&gt;
              @@GetComponent(Field,'Product')@@
         &lt;!-- TemplateBeginRepeat name="Product.Fields" --&gt;
    @@Field.Name@@
    &lt;!-- TemplateBeginRepeat name="Field.Values" --&gt;
      &lt;!-- TemplateBeginIf cond="Field.ContentType = 'text/plain'" --&gt;      
      @@RenderComponentField(FieldPath, TemplateRepeatIndex)@@
      &lt;!-- TemplateEndIf --&gt;
      &lt;!-- TemplateBeginIf cond="Field.ContentType = 'tridion/field'" --&gt;
        &lt;!-- TemplateBeginRepeat name="Field.Fields" --&gt;
          @@Field.Name@@
          &lt;!-- TemplateBeginRepeat name="Field.Values" --&gt;
            @@RenderComponentField(FieldPath, TemplateRepeatIndex)@@        
          &lt;!-- TemplateEndRepeat --&gt;
        &lt;!-- TemplateEndRepeat --&gt;
      &lt;!-- TemplateEndIf --&gt;
    &lt;!-- TemplateEndRepeat --&gt;
  &lt;!-- TemplateEndRepeat --&gt;
  </code></pre>
  
  <p><br><a href="http://img9.imageshack.us/img9/8859/schemadesign.jpg" rel="nofollow">UML diagram</a></p>