2

[Premise]

I create a schema having text field (not RTF).

and I create TBB using c# that convert value of text field to html source.

i show a part of that TBB below.

                val = ((TextField)field).Value;

                package.PushItem(field.Name , package.CreateHtmlItem(val));

[Problem]

I enter below value to text field using above schema, as described below.

 <script type="text/javascript">
    // <![CDATA[
    &
    // ]]>
  </script>

next, i preview(render with CT) the component. it convert below

  <script type="text/javascript">
    // 
    &amp;
    // 
  </script>

but I enter below value to text field using above schema, as described below.

 <script type="text/javascript">
    // <![CDATA[
    &
    // ]]>
  </script></div>

next, i preview(render with CT) the component. it don't convert below

  <script type="text/javascript">
     // <![CDATA[
     &
     // ]]>
  </script></div>

i guess that tridion convert above. why happen this? (The CT use one tbb and one DWT only. TBB is above TBB. DWT is the output of tbb)

using Template Builder, I know that TBB output don't be converted ,but DWT output is conveted.

I show DWT source below.

@@field.Name@@

[More]

I enter below value to text field using above schema, as described below.

<div>&amp;</div>

<script type="text/javascript">
    // <![CDATA[
    &
    // ]]>
</script>

i preview(render with CT) the component. it convert below

<div>&amp;</div>

<script type="text/javascript">
    // 
    &amp;
    // 
</script>

but I enter below value to text field using above schema, as described below.

<div>&</div>

<script type="text/javascript">
    // <![CDATA[
    &
    // ]]>
</script>

i preview(render with CT) the component. it don't convert below.

<div>&</div>

<script type="text/javascript">
    // <![CDATA[
    &
    // ]]>
</script>
2

When you render HTML based items from the package they are escaped for you (turning your & into &amp;)

Instead of using Package.CreateHtmlItem(), try using Package.CreateStringItem() instead:

 val = ((TextField)field).Value;
 package.PushItem(field.Name , package.CreateStringItem(ContentType.Text, val));
  • the above method, field of value is text , but of html source, isn't it. rendering with ct, field of the value is interpreted as html. so i use (package.CreateHtmlItem(val)). Is my understanding right? – Arai Yuhei Feb 27 '15 at 7:27
  • Most of your field is not HTML. Most of it is script. I would not recommend mixing the two for this reason. Perhaps the script tags should be in your DWT and only the script should come from your text field? Did you try the code? – David Forster Feb 27 '15 at 9:12
  • thank you answering my question. text field is written by html source(ex. a, div, img, source, movie, li, ul and script and so on). script tags is different each component. so script tag can't be written in DWT. my text field is not only script tag but also a tag , div tag and so on. – Arai Yuhei Mar 1 '15 at 4:58
  • i describe more information. please look [More] on this article. – Arai Yuhei Mar 1 '15 at 5:23

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.