We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15796
    • 24 Posts
    Ok, so I’ve got a newspublisher setup which links to a form-chunk etc.
    It all works except for 1 thing: when someone types into the content section of the form it is typed using linebreaks(so just an enter at the end of the line) and it is stored this way, but when displaying it it is all displayed on one single line.

    As it is stored correctly, I don’t think the problem lies within the form but within the template-chunk I use to display it, right?

    But that is nothing more than this:

    <h3>[*pagetitle*]</h3><br/>
    [*longtitle*]<br/><br/>
    [*description*]<br/>
    [*content*]<br/>


    what am I doing wrong?
    • Check the actual value in the database; I’ll bet the /n is there; but these don’t work in web browsers. The /n linebreaks need to be changed to
      tags.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 15796
        • 24 Posts
        actually the database contains neither /n nor

        the field (which is of type mediumtext as it is a mysqlserver) contains the text like it should look.

        so this tells me the problem occurs when displaying it, but I don’t see why
        [*content*]<br/>
        would display it all on 1 line.
          • 3749
          • 24,544 Posts
          Look at that tpl chunk in the database. If it looks like you’ve shown it, there’s no way I know of that a browser could display it all on one line. If it looks as you’ve shown it, it’s a good bet that either the template chunk isn’t being used, or the "content" field contains all the information.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 15796
            • 24 Posts
            database says
            <h3>[*pagetitle*]</h3>

            [*longtitle*]


            [*description*]

            [*content*]


            when changing the template chunk, the pages which use it change along so it is being used correctly and when going to the page using the manager, the content field shows the correct info.
              • 3749
              • 24,544 Posts
              I’m not sure I understand you. The text that a user enters in the Content field will always be rendered with no breaks unless it’s processed by a Rich Text editor or a plugin to add HTML tags (<p> and/or
              ) to break it up.

              I think some people have figured out how to implement a RTE in the front end but I’m not sure it can be done with NewsPublisher. There may also be a plugin that does what you want.

              The alternative is to teach the users to enter HTML.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 18913
                • 654 Posts
                In NewsEditor (based on NewsPublisher) the solution to this is to change this bit of code

                      // format content
                      $content = $modx->stripTags($_POST[$rtcontent],$allowedTags);
                


                to this

                      // format content
                      $content = $modx->stripTags(nl2br($_POST[$rtcontent]),$allowedTags);  //MattC
                


                Assuming the "allowedTags" string hasn’t been changed, this worked for me.

                BTW, if someone knows of a link to getting a RTE working for a form field, I’d appreciate seeing it ...
                Matt