1

Created Schema A which has field called keys which is embeeded schema type. The embeeded schema consists of two fields called name and value.

Created Component A using schema A.

created parameter schema which has the field called component path in the default vale given the webdav path of the component A.

Now want to read the parameter schema and the field of the parameter schema also (component path)

parameter scheam assigning to the DWT TBB.

Please provide your inputs.

2

1 Answer 1

3

It's a bit unclear from you question, but I think I somewhat understand what you are looking to do (or I'm way off and totally jumped the gun). I'm going to make some assumptions here in hopes that it clears up what you are looking for.

  • You have a component, Component A, which has repeated Key / Value pair fields. We'll assume that the name of the field that contains the multi-embedded fields is called "Pairs", and the name of the embedded fields are "Key" and "Value".
  • You have a parameter schema with a text field. Let's assume for this example it has a single text field, "MyComponentField".
  • You have a DWT that you've attached your parameter schema, and for the value of "MyComponentField", you've specified the web dav url to Component A.
  • You want to be able to read the webdavurl from the parameter's "MyComponentField", open up the component, and read the key value pairs from Component A.

Assuming the above is correct, the DWT TBB is probably not the place that you want to attach your parameter schema to. You'll most likely want to create another TBB, we'll call it "GetWebDavFieldComponent", and attach the parameter schema to this rather than the DWT. Your code for this TBB should look like:

[TcmTemplateTitle("Get WebDav Field Component")]
public class GetWebDavFieldComponent : ITemplate
{
    public void Transform(Engine engine, Package package)
    {
        string componentWebDav = package.GetValue("MyComponentField");
        Component component = engine.GetObject(componentWebDav) as Component;
        Item componentItem = package.CreateTridionItem(ContentType.Component, component);
        package.PushItem("MyWebDavComponent", componentItem);
    }
}

Notice the package.GetValue("MyComponentField"), this is what's getting your webdav value that you specified in the attached parameter schema. From this webdav value, we then retrieve the component and push it to the package.

Now that the component is added to your package with the given name "MyWebDavComponent", you can now access this component from your DWT. Here's a DWT example that outputs the title of that component added by the parameter schema loops over those key value pairs and outputs their values.

<h2>Parameter Component Title: @@MyWebDavComponent.Title@@</h2>
<h3>Parameter Component Fields:</h3>
<!-- TemplateBeginRepeat name="MyWebDavComponent.Fields.Pairs" -->
    <div>
        <strong>@@Field.Key@@:</strong> @@Field.Value@@
    </div>
<!-- TemplateEndRepeat -->

Hope that helps! You'll want to of course add some error handling (for example, what if there is no component found from the given webdav url). Also I'd strongly suggest reading up on the templating sections of the Tridion documentation.

Your Answer

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

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