4

I have a Tridion 2013 instance with a custom ECL provider, and we're using DD4T 1.30.

I've got DD4T set up and working, but I've just come to publish a page with a component that has a ECL Multimedia Link, and I'm getting the following failure message:

Invalid URI: ecl:10-myeclprovider-105-aba-file.

The page template is using the following TBBs:

  • Add inherited metadata to page
  • Publish binaries for page
  • Generate dynamic page
  • Preview page

The component template is using the following TBBs:

  • Publish binaries for component
  • Generate dynamic component

I'm guessing something in DD4T's "Publish binaries for page" or "Publish binaries for component" TBBs, expects standard Multimedia Links, rather than ECL ones.

Or am I missing something else?

Any help much appreciated.

UPDATE:

I tried the suggestions given below, with no joy unfortunately.

We initially tried to fix the problem by modifying the component in the Package with a custom TBB, but when we have a component with an ECL multimedia link that is accessed via a Component Link, the problem returns as that linked component isn't in the Package.

It appears that instantiating a Tridion.ContentManager.ContentManagement.Fields.ItemFields object with a component that has a ECL Multimedia Link throws an exception, as it tries to load the href attribute value as a TCM URI.

We've temporarily sorted this out by checking out the DD4T source code and making a modification to anywhere the TBBs attempt to load a new ItemFields object.

We check the Component.Content field for any ECL IDs, and re-write them to TCM IDs:

var eclSession = SessionFactory.CreateEclSession(Engine.GetSession());

var content = component.Content;
var ns = new XmlNamespaceManager(content.OwnerDocument.NameTable);
ns.AddNamespace("xlink", "http://www.w3.org/1999/xlink");

var eclItems = content.SelectNodes("//*[starts-with(@xlink:href, 'ecl:')]", ns);

foreach (XmlNode eclItem in eclItems)
{
    var attribute = eclItem.Attributes["xlink:href"];
    var eclUri = eclSession.HostServices.CreateEclUri(attribute.Value);
    var tcmUri = eclSession.GetOrCreateTcmUriFromEclUri(eclUri);

    if (!string.IsNullOrEmpty(tcmUri))
    {
        attribute.Value = tcmUri;
    }
}

Obviously, this isn't the nicest solution, but allows us to continue work for now. Again, any suggestions for a more concrete fix would be appreciated.

5

I don't think it matters much if you insert Bart's TBB into the template before the DD4T TBBs. The problem is that DD4T's "Publish binaries for xxx" TBB will still throw this exception because it always does an AddBinary call on the URI, and that is not supported for ECL URIs.

To solve this, I think it is necessary to merge Bart's code with the DD4T TBBs, especially the method ResolveEclItem. Maybe someone from the DD4T community who (unlike me) has access to an environment with ECL can take this on?

  • 3
    I will be doing this at some point on my current project and do intend to to contribute some form of generic ECL binary handling code back if possible – David Forster Nov 13 '13 at 23:11
  • That would be very much appreciated, David! – Quirijn Nov 14 '13 at 8:58
  • @Quirijn or make sure that the DD4T Publish Binaries TBB works like the SDL Tridion default ones and checks if the Item in the Package already as a Item.ItemPropertyPublishedPath set and then uses that rather than calling Add Binary itself. Both options would work, but I think mine means less work for everybody and more flexibility. But I still haven't gotten around myself to look at it and see what actually is needed to make it work, there might still be additional work required for the template fragments of ECL... – Bart Koopman Nov 14 '13 at 13:29
  • @Quirijn btw. if you have a 2013 environment you can simply install my free Flickr ECL provider and make DD4T work with that (as an MVP you have a dev license ;o). – Bart Koopman Nov 14 '13 at 13:33
4

I am also encountering this problem at the moment and you are correct, DD4T does not currently handle ECL item links because it thinks they are just regular multimedia links.

As with the other means of templating in Tridion and the External Content Library functionality, "You need to develop Template Building Blocks that interact with the External Content Library API to use media stored in an external system in SDL Tridion-driven Web sites." (from External Content Library API)

In other words, you'll need to either extend the binary handling code of DD4T or (if possible) create a TBB that deals with the ECL links before the problem with the Publish Binaries TBBs occur. At a high level, you'll need to detect whether the item is a regular multimedia link or an ECL link and then handle it accordingly using the existing DD4T Tridion TOM.Net API code (or leaving the Publish Binaries TBBs to do it for you) or the ECL API as appropriate.

You also have choices when it comes to dealing with your ECL items. Depending on what your provider can give you, you can publish a reference to an external url of the item, publish the item as a binary in full, or maybe even both. You might also wish to do this differently per provider, so there's a bit of scope for customisation and you need to plan accordingly.

You can find out more about how you could use the ECL API in Bart's 2013 ECL TBB on SDL Tridion World and a little about how you could implement your own DD4T TBB to add the data in Quirijn's answer to How do I hook up DD4T.ContentModel.IComponent.Multimedia.AltText to my metadata field value?

P.S. I haven't looked too much into this yet as I've been dealing with other stuff. If you see a nice way to handle ECL links in a generic fashion (i.e. that would work for everyone) it might be a nice contribution back to the DD4T project (and save me a lot of work!) :)

3

I would be tempted to say it all depends on your external content/system and the ECL provider you wrote. But actually I find that most of the times it is really simple, as long as you make sure to resolve the ECL items.

Basically the main thing you need to remember is that an ECL item can be published as a binary or resolved to a direct link. Now if it is going to be published as a binary, you will need to resolved it via a TBB and get its content so you can call AddBinary. But when you have a direct link to an already published item, you will need to resolve the link in the Component to the ECL uri to that.

I have written a standard TBB for resolving ECL items, which will work for both cases (determined by the fact if there is a direct link available or not). You can find the source of it on Google code.

Now for DD4T you might have to tweak the TBB a little, but try adding it as the first TBB in your Template and it might already be fine. Either the ECL item is published (as a variant) or the link is resolved to a direct link on the internet. Just as long as you understand that if you find an ECL uri on the Presentation Server or in the Broker DB, you have a problem. ECL can only be resolved on the CM side.

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.