KarlvonKarton Posted September 25, 2018 Share Posted September 25, 2018 Hello Forum, Yet another question. I'm importing data from an old database structure into Processwire. But when I import following data into a textarea (the standard Body one) then I get a lot of <p> </p> for some odd reason. Someone has a clue? I have used several approaches. // this $text = nl2br($r['textEN']); // but also this $text = $sanitizer->textarea($r['textEN'],array('multiLine'=>false,'newlineReplacement'=>'<br>','stripTags'=>false)); // // no difference The data from a text field in mysql: <table border="1" cellspacing="0" cellpadding="0"> <tbody><tr> <td width="403"><p><strong><em>Results</em></strong></p></td> <td width="95"><p align="right"><strong>30.06.2017</strong></p></td> <td width="96"><p align="right"><strong>30.06.2016</strong></p></td> </tr> <tr> <td><p>Operating result</p></td> <td><p align="right">11,402</p></td> <td width="96"><p align="right">10,163</p></td> </tr> <tr> <td><p>Net result of the year</p></td> <td><p align="right">3,853</p></td> <td width="96"><p align="right">2,688</p></td> </tr> <tr> <td><p>Share of the group in the net result of the year</p></td> <td><p align="right">3,888</p></td> <td width="96"><p align="right">2,689</p></td> </tr> <tr> <td><p><strong><em>Balance sheet</em></strong></p></td> <td><p align="right"><strong>30.06.2017</strong></p></td> <td width="96"><p align="right"><strong>31.12.2016</strong></p></td> </tr> <tr> <td><p>Total assets</p></td> <td><p align="right">641,120</p></td> <td width="96"><p align="right">605,547</p></td> </tr> <tr> <td><p>Cash and cash equivalents</p></td> <td><p align="right">17,263</p></td> <td width="96"><p align="right">15,273</p></td> </tr> <tr> <td><p>Net financial debt (-)</p></td> <td><p align="right">360,423</p></td> <td width="96"><p align="right">341,263</p></td> </tr> <tr> <td><p>Total equity</p></td> <td><p align="right">214,257</p></td> <td width="96"><p align="right">210,408</p></td> </tr> </tbody></table> The result in the textarea Body (source view): <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <table border="1" cellpadding="0" cellspacing="0"> <tbody> <tr> <td> <p><strong><em>Results</em></strong></p> </td> <td> <p><strong>30.06.2017</strong></p> </td> <td> <p><strong>30.06.2016</strong></p> </td> </tr> <tr> <td> <p>Operating result</p> </td> <td> <p>11,402</p> </td> <td> <p>10,163</p> </td> </tr> <tr> <td> <p>Net result of the year</p> </td> <td> <p>3,853</p> </td> <td> <p>2,688</p> </td> </tr> <tr> <td> <p>Share of the group in the net result of the year</p> </td> <td> <p>3,888</p> </td> <td> <p>2,689</p> </td> </tr> <tr> <td> <p><strong><em>Balance sheet</em></strong></p> </td> <td> <p><strong>30.06.2017</strong></p> </td> <td> <p><strong>31.12.2016</strong></p> </td> </tr> <tr> <td> <p>Total assets</p> </td> <td> <p>641,120</p> </td> <td> <p>605,547</p> </td> </tr> <tr> <td> <p>Cash and cash equivalents</p> </td> <td> <p>17,263</p> </td> <td> <p>15,273</p> </td> </tr> <tr> <td> <p>Net financial debt (-)</p> </td> <td> <p>360,423</p> </td> <td> <p>341,263</p> </td> </tr> <tr> <td> <p>Total equity</p> </td> <td> <p>214,257</p> </td> <td> <p>210,408</p> </td> </tr> </tbody> </table> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> PS: sorry for the long markup/post... ? Link to comment Share on other sites More sharing options...
kongondo Posted September 25, 2018 Share Posted September 25, 2018 (edited) I'm pretty sure it's CKEditor doing that and not sanitizer->textarea(); Maybe this will help? Edited September 25, 2018 by kongondo 2 Link to comment Share on other sites More sharing options...
Robin S Posted September 26, 2018 Share Posted September 26, 2018 On 9/26/2018 at 6:28 AM, KarlvonKarton said: I have used several approaches. // this $text = nl2br($r['textEN']); // but also this $text = $sanitizer->textarea($r['textEN'],array('multiLine'=>false,'newlineReplacement'=>'<br>','stripTags'=>false)); // // no difference I think the problem here is that you are replacing newlines with <br>, but that doesn't make sense for the content you are importing. If your content consists of markup then you don't want newlines to become <br>s because the newlines exist in the markup just for code readablity and aren't something that should result in new HTML tags in the saved field value. If you set the field value directly from $r['textEN'] then it should work. 2 Link to comment Share on other sites More sharing options...
KarlvonKarton Posted September 27, 2018 Author Share Posted September 27, 2018 15 hours ago, Robin S said: If you set the field value directly from $r['textEN'] then it should work. Exact! Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now