Search code examples
tridiondreamweaver-templates

Tridion 2009 SP1: Dreamweaver Template Error: ConvertURLToPath() can't decode URL: invalid escape


I'm trying to use a Get Label TBB in a Dreamweaver Template that parses expressions like %%LabelKey%% and replaces them with a value from a Component that is stored in Publication metadata.

I'm trying to use a label to store an absolute URL (e.g. http://www.example.com) but am getting the following in Template Builder when trying to run the template

Error: ConvertURLToPath() can't decode URL: invalid escape

The DWT code looks similar to:

<a href="%%LogoLink%%" target="_blank" title="%%LogoLinkTitle%%" class="logo">
    <img src="@@Page.Publication.Metadata.parent_logo@@" width="95" height="24"
         alt="@@parent_logo0.alt@@">
</a>

The problem is caused by %%LogoLink%%. If I remove that the template works fine. Why is Tridion trying to do something with this value? I thought it would only try and resolve it if it was tridion:href.

Any help appreciated.

Full stack trace:

Engine: Error in Engine.Transform Error: ConvertURLToPath() can't decode URL: invalid escape at Tridion.ContentManager.Session.GetTcmUri(String uri) at Tridion.ContentManager.Session.GetObject(String uri) at Tridion.ContentManager.Session.IsExistingObject(String uri) at Tridion.ContentManager.Templating.Engine.GetObject(Session session, String itemUriOrWebDavUrl) at Tridion.ContentManager.Templating.Engine.GetObject(String itemUriOrWebDavUrl) at Tridion.ContentManager.Templating.Templates.ExtractBinariesFromHtmlTemplate.ResolveWebDavUrl(String urlToResolve, String webDavBaseUrl, Engine engine) at Tridion.ContentManager.Templating.Templates.ExtractBinariesFromHtmlTemplate.ResolveTemplateBinaries(Engine engine, Package package, TcmUri baseItemTcmUri, ExtractBinariesContentWrapper contentWrapper) at Tridion.ContentManager.Templating.Templates.ExtractBinariesFromHtmlTemplate.Transform(Engine engine, Package package) at Tridion.ContentManager.Templating.Dreamweaver.DreamweaverMediator.RegisterTemplateBinaries(Package package, String baseItemTcmUri, String templateString) at Tridion.ContentManager.Templating.Dreamweaver.DreamweaverMediator.Transform(Engine engine, Template templateToTransform, Package package) at Tridion.ContentManager.Templating.Engine.ExecuteTemplate(Template template, Package package) at Tridion.ContentManager.Templating.Engine.InvokeTemplate(Package package, TemplateInvocation templateInvocation, Template template)
at Tridion.ContentManager.Templating.Compound.CompoundTemplateMediator.Transform(Engine engine, Template templateToTransform, Package package) at Tridion.ContentManager.Templating.Engine.ExecuteTemplate(Template template, Package package) at Tridion.ContentManager.Templating.Engine.InvokeTemplate(Package package, TemplateInvocation templateInvocation, Template template)
at Tridion.ContentManager.Templating.Engine.TransformPackage(Template template, Package package) at Tridion.ContentManager.Templating.Engine.TransformItem(Template template, IdentifiableObject itemToRender) at Tridion.ContentManager.Templating.Debugging.DebuggingEngine.Run()
at Tridion.ContentManager.Templating.Debugging.DebugSession.Run()


Solution

  • When you upload a DWT Tridion tries to map that <img src=... in your DWT to a Multimedia Component. This step is needed to ensure that a DWT works fine with BluePrinting (which requires the values to stored as TCM URIs) AND is always viewable in Dreamweaver (which requires file paths).

    To do this mapping, Tridion takes the path in any src or href attributes (as well as any CSS import or url() construct) and looks for a Multimedia Component in that location relative to the DWT.

    So if a DWT that is stored under /Building Blocks/System/Designs/My Page Design and it contains:

    <img src="../Images/MyHeader.jpg"></img>
    

    Then Tridion will look for a Multimedia Component called /Building Blocks/System/Images/MyHeader.jpg and replace the src value if it finds a match:

    <img src="tcm:1-23"></img>
    

    In your DWT the %%LogoLink%% is causing problems, since it looks like it is URL-encoded (the % sign is used as an escape character in URLs), but in reality isn't.

    Most people encountering similar problems end up using an alternate escape sequence in their DWT and write a small post-processing TBB that converts that escape sequence back into %% after the DWT is executed. In your case just picking a non-conflicting escape syntax would be enough.