I have a Dexterity Multiline Text field called dcdl_priority with 3 lines of information separated by hitting the return key:
Sentence 1
Sentence 2
Sentence 3
I have the following codes in my view template:
<tr tal:condition="context/dcdl_attention">
<td><strong>DCDL Attention:</strong></td>
<td><span tal:content="context/dcdl_attention" /></td>
</tr>
This is what I get:
Sentence 1 Sentence 2 Sentence 3
I would like the input displayed on my page in the follow way:
Sentence 1
Sentence 2
Sentence 3
I am sure my TAL codes are incorrect. Any help would be most appreciated. Thank you.
zopyx
(Andreas Jung)
April 19, 2018, 7:18pm
3
Andreas, yes, I have seen that documentation. My bad, I realized that my title is incorrect. I am looking at a multiline text field and not a richtext field. This is what I tried so far:
<tr tal:condition="context/dcdl_attention">
<td><strong>DCDL Attention:</strong></td>
<td><span tal:content="structure context/body/output" /></td>
</tr>
<tr tal:condition="context/dcdl_attention">
<td><strong>DCDL Attention:</strong></td>
<td><span tal:content="structure context/dcdl_attention/body/output" /></td>
</tr>
My page no longer loads.
espenmn
(Espen)
April 19, 2018, 9:12pm
5
In my opinion, you should use schema.List and not Textfield, that way you could index your field easier (?) also.
If that was the case, the TAL would be something like:
<td tal:repeat"dcdl_line context/dcdl_attention">
${dcdl_line}
</td>
Espen, yes, that would be a better option if we had a set list. However, we would like people to add their own statements, one per line. I guess I could actually use a richtext field to do so but I was curious if I could list out the statements one per line from a multi-textfield.
espenmn
(Espen)
April 19, 2018, 9:51pm
7
You could do that in a list too, I think
You could probably do that too, but it feels more natural to put this logic in a py file instead of in the browser view
You might be able to do it with similar syntax to what I suggested (not sure what you mean by 'multi-textfield'), you could try …
cdw9
(Chrissy Wainwright)
April 19, 2018, 9:55pm
8
I'm sure I've done this before.. after a quick search I found this option, tough I don't remember if it was the fix. Try to wrap the content in a <pre>
<pre tal:content="context/dcdl_attention" />
espenmn
(Espen)
April 19, 2018, 10:37pm
9
If you use pre, you might need to add some CSS
Chrissy and Espen, thank you so much! The <pre>
tag and white-space CSS property did the trick. Thank you so much!!!