Text version not showing line breaks

Avatar

Avatar

Pabst_dk

Avatar

Pabst_dk

Pabst_dk

01-09-2017

Hi,

Whats best way to get the "Text version" to show the text with line breaks?

Im running on a AC platform version 6.1.1 Build 8770

Currently Im just getting a blankspace instead of the linebreak.

What i have done:

Created a .js template with the code below.

<% if ( content.@textVersion != '' ) { %><%= content.@textVersion%><% } else { %> No Text content inserted<% } %>

Added this to my Publication template as a Text model

1290410_pastedImage_21.png

Created the attribute in my schema.

<attribute label="Text Version" name="textVersion" type="memo" xml="true"/>

Created a tab with this attribute in my template.

    <container codepage="1252" img="xtk:text.png" label="Text Version">

      <container codepage="1252" label="Basic" type="frame">

        <input xpath="@textVersion"/>

      </container>

    </container>

Results:

example:

Hi,

Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit.

Best Regards,

Output:

Hi,  Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit.  Best Regards,

Thanks in advance,

Jonas

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Pabst_dk

Avatar

Pabst_dk

Pabst_dk

04-09-2017

Hi Jean-Serge,

No problem,

I tested out the other suggestions as well without any positive result.

So I got started to read all examples on setting up forms in AC and to test all possible ways to get the field to be working, and ended up with changing the form from attribute to element which gives me the correct rendering of the content.

Thanks for the help on ending up with a solution

Now the client has changed their mind and want a HTML fallback.

So ill need to get my head around building that one now..

Best Regards,

Jonas

Answers (5)

Answers (5)

Avatar

Avatar

Pabst_dk

Avatar

Pabst_dk

Pabst_dk

05-09-2017

Hi Jean-Serge,

I was quite weird to notice that this would solve the trick.

But I'm glad that this did the trick.

The customer always has the last word

Best Regards,

Jonas

Avatar

Avatar

Jean-Serge_Biro

MVP

Avatar

Jean-Serge_Biro

MVP

Jean-Serge_Biro
MVP

04-09-2017

Hi Jonas,

Happy to know that the wrong behaviour was due to attribute instead of element use, even though quite weird, it is useful to know it.

And for customer requirement change, in France we say "Customer is king"

By the way, please may you close this ticket? Many thanks in advance.

Best Regards.
Jean-Serge

Avatar

Avatar

Jean-Serge_Biro

MVP

Avatar

Jean-Serge_Biro

MVP

Jean-Serge_Biro
MVP

01-09-2017

Hi Jonas,

Sorry, I was wrong in my previous post.

First of all, because you need to keep xml="true" to get mData type, in case of your raw text exceeds the DB varchar size limitation (4000 or 8000 characters usually depending on the DB) so it is better to keep NTEXT /CLOB DB type to store the raw text as for html.

So keep the attribute declaration as is:

<attribute label="Text Version" name="textVersion" type="memo" xml="true"/>

In AC documentation I read only "memo" or "html" values for an element or attribute declaration of type xml.

But to my mind, I think you should keep "memo" type.

What I forgot to mention in my 1st post, is that the input type must be set accordingly in the form declaration:

So instead of writing this:

<input xpath="@textVersion"/>

you should write this:

<input xpath="@textVersion" type="CodeEdit" contentType="txt" />

with readOnly attribute set depending on your need.

See JSAPI documentation for CodeEdit type values, and also factory forms declarations for other values not described in the JSAPI documentation.

Regards
J-Serge

Avatar

Avatar

Pabst_dk

Avatar

Pabst_dk

Pabst_dk

01-09-2017

Hi Jean-Serge,

Unfortunately that did not do the trick.

The customer has asked for the solution with an empty field and no auto generated text.

But i will try to get this to work with my solution to have it as a proper fallback.

Thanks,

Best Regards,

Jonas

Avatar

Avatar

Jean-Serge_Biro

MVP

Avatar

Jean-Serge_Biro

MVP

Jean-Serge_Biro
MVP

01-09-2017

Hello Jonas,

Please may you test by changing the xml type attribute:

<attribute label="Text Version" name="textVersion" type="memo" xml="false"/>

In your case, the memo field should contain raw text type.

Because XML management rule is to not take into account several spaces, line breaks etc. It is up to the XSLT engine to render it/display it with line break, indentation, etc, depending on the XSLT style sheet defined.

By the way, one suggestion: why don't you generate the text version when empty by using the nms:delivery.HtmlToText(htmlContent) method instead of putting "No text content inserted" string? Even if not ideally generated from html content, it is probably better than nothing no "No text content inserted", isn't it?

Regards
Jean-Serge