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.