We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27117
    • 28 Posts
    Hi everyone

    I have a TV with input type textarea and output type standard. I would like to use this text area for filling in an adress. For example:

    Company Name
    Adress
    ZIP/City

    This works fine, until the content of the TV is displayed in my template. The Problem is, that there are no longer line breaks and it shows like this (everything in one line):

    Company Name Adress ZIP/City

    Is there a easy way, that the line breaks will be stored with the content of the TV?

    Thank you
      Modx 2.1.3, PHP 5.2
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Line breaks aren’t recognized by HTML, you have to use some mechanism for converting the line breaks into
      tags; or enclose the whole thing in <pre>...</pre> tags, which will recognize line breaks. You could do that using the "HTML generic tag" widget, specifying pre as the tag name. Or make up your own custom output formatting snippet and use the PHP nl2br() function. You might also be able to do something with a PHx modifier.

      http://wiki.modxcms.com/index.php/Adding_TV_Widgets_without_hacking_the_core
      http://www.php.net/manual/en/function.nl2br.php
      http://wiki.modxcms.com/index.php/PHx#nl2br
        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
        • 27117
        • 28 Posts
        Thank you Susan

        I tried a solution with te PHP nl2br() function.

        I created a snippet with the following code:
        <?php
        echo nl2br("[[*myTVName]]");
        ?>
        


        Then, in my template, I just call this snippet instead of the TV but the result is the same. There are absolutely no
        Tags in the source code, not even in the beginning of the first line. Thats very strange.
          Modx 2.1.3, PHP 5.2
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I’m not sure about Revo, but in Evo you can’t use tags like that in the PHP code, you have to use one of the API functions to fetch the TV value.
            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
            • 27117
            • 28 Posts
            Got it! smiley

            just add :nl2br at the end of the tv name and it works!

            [[*myTVname:nl2br]]


            life can be easy in Revo!

            Thank you anyway for your help.
              Modx 2.1.3, PHP 5.2