Tridion: Dreamweaver does not allow HTML code field

We have a composite CT that displays the code field of one of the components.

A part of the TT dream weavers is as follows:

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

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

For example: if the code field has a value like β†’ <div align="center" id="loginapp"></div> Then the same value is displayed on the page instead of parsing.

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

I know this can be solved if we use C #. But is there a way to use Dreamweaver to stop converting special characters?

+4
source share
4 answers

Thank you for your help. After many trials with Dreamweaver code, we decided to use C # TBB instead, which solved the goal.

Also, reading a multi-line field as a text field was one of the mistakes we made. This caused the field value to be displayed on the page instead of rendering as code.

Finally, we solved the problem using "MultilineTextField".

+1
source

You should use dwt to publish the code on the server, I mean create a new dwt for each code and just paste the code into dwt. you can use this dwt with component component or resource type.

or if you want to use a text field, try running the tbb code. add this tbb to 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(); } } 
+6
source

If I remember correctly, it depends on your type of field, if you use a plain text field in your scheme, then HTML is escaped, if you use a field with extended text, it will be allowed.

Perhaps the option is to write a custom Dreamweaver function that allows you to undo a field (present it as an HTML field, not a text field). As you already mentioned, you can also do this in TBB, but Dreamweaver custom functions can be called directly from the DWT template. In any case, I think you really need to do some encoding yourself.

+4
source

RenderComponentField has two parameters: bool htmlEncodeResult and bool resolveHtmlAsRTFContent. Do you use this built-in function?

+2
source

Source: https://habr.com/ru/post/1433543/


All Articles