Huston Lopes
Huston Lopes

Reputation: 622

Tridion: Dreamweaver doesn't resolves the HTML code field

We have a compound CT, which outputs the code field of one of the component.

The dream-weaver part of CT is as follows:

<!-- TemplateBeginRepeat name="Component.HTMLCode" -->
    @@Component.HTMLCode@@
<!-- TemplateEndRepeat -->

However this CT displays the code field on the page, instead of converting into HTML.

For eg: If the code field has a value as -> <div align="center" id="loginapp"></div> Then this same value is displayed on page instead of parsing.

In the page source, we get output as "&lt ;div align=&quot ;center" id=&quot ;loginapp&quot ;&gt ;&lt ;/div&gt ;"

I know this can be resolved if we use C#. But is there any way using dreamweaver to stop the conversion of special characters?

Upvotes: 4

Views: 923

Answers (4)

Huston Lopes
Huston Lopes

Reputation: 622

Thanks for your help. After lots of trials with dreamweaver code, we decided to use C# TBB instead which solved the purpose.

Also reading the multiline field as a textfield was one of the mistake we committed. This caused the field value to be displayed on page instead of rendering as a code behind.

We finally solved the issue using "MultilineTextField".

Upvotes: 1

vikas kumar
vikas kumar

Reputation: 2444

You should use dwt to publish the code to server, I mean create new dwt for every code and just paste the code in the dwt. you can use this dwt with emply component or resource type component.

or if you want to use text field, try following tbb code. add this tbb at the end of the template.

public override void Transform(Engine engine, Package package)
    {


        Regex objExp = new Regex(@"&#\d+;", RegexOptions.IgnoreCase);
        Regex objDecExp = new Regex(@"[^0-9]", RegexOptions.IgnoreCase);

        this.Initialize(engine, package);
        string strPackage = package.GetValue("Output");

        strPackage = unescapeHTML(strPackage);

        strPackage = objExp.Replace(strPackage, delegate (Match match)
        {

            string strInput = match.ToString();
            strInput = objDecExp.Replace(strInput, "");


            int intValue = Convert.ToInt32(strInput);
            char strChar = (char)intValue;

            return strChar.ToString();
        });



        strPackage = strPackage.Trim();

        Item objOutput = package.CreateStringItem(ContentType.Html, strPackage);
        package.PushItem("Output", objOutput);

    }

    private string unescapeHTML(string strInput)
    {
        StringBuilder strOutput = new StringBuilder(strInput);
        strOutput.Replace("&quot;", "&#34;");
        strOutput.Replace("&nbsp;", "&#32;");
        strOutput.Replace("&amp;", "&#38;");
        strOutput.Replace("&apos;", "&#39;");
        strOutput.Replace("&lt;", "&#60;");
        strOutput.Replace("&gt;", "&#62;");
        strOutput.Replace("&iexcl;", "&#161");
        strOutput.Replace("&cent;", "&#162");
        strOutput.Replace("&pound;", "&#163");
        strOutput.Replace("&curren;", "&#164");
        strOutput.Replace("&yen;", "&#165");
        strOutput.Replace("&brvbar;", "&#166");
        strOutput.Replace("&sect;", "&#167");
        strOutput.Replace("&uml;", "&#168");
        strOutput.Replace("&copy;", "&#169");
        strOutput.Replace("&ordf;", "&#170");
        strOutput.Replace("&not;", "&#172");
        strOutput.Replace("&shy;", "&#173");
        strOutput.Replace("&reg;", "&#174");
        strOutput.Replace("&macr;", "&#175");
        strOutput.Replace("&deg;", "&#176");
        return strOutput.ToString();    
    }


}

Upvotes: 6

Arjen Stobbe
Arjen Stobbe

Reputation: 1684

RenderComponentField has two parameters: bool htmlEncodeResult, and bool resolveHtmlAsRTFContent. Are you using this built in function?

Upvotes: 2

Bart Koopman
Bart Koopman

Reputation: 4835

If I recall correctly it is depending on your fieldtype, if in your Schema you use a normal text field, then HTML is escaped, if you use a rich text field, it will be resolved.

An option would perhaps be to write a Dreamweaver Custom function which allows you to unescape the field (represent it as an HTML field rather than a text field). As you mentioned you could also do it in a TBB, but the Dreamweaver Custom Functions are directly callable from the DWT Template. Either way I think you indeed need to do some coding yourself.

Upvotes: 4

Related Questions