prevent changing newlines to <br />

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tfederman
    New Member
    • Dec 2005
    • 6
    • 3.5.x

    prevent changing newlines to <br />

    When I have HTML turned on and want to let people post tables, all the newlines changing to <br /> screw up the table. How do I prevent that?

    This isn't for allowing regular users to post html code, I'm letting my staff use a special forum as a CMS for news pages. What's the preferred method for doing that? I'm just querying the post/post_parsed tables directly.

    Thanks.
  • Wayne Luke
    vBulletin Technical Support Lead
    • Aug 2000
    • 73387
    • 6.0.X

    #2
    It would require code modification. Most likely you could probably add a hook to bbcode_parse to override this.
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API

    Comment

    • tfederman
      New Member
      • Dec 2005
      • 6
      • 3.5.x

      #3
      Thanks for the tip. It looks like this does the trick:

      PHP Code:
      if ( strpos($text'<table') !== false )
      {
          
      $text str_replace('<br />'''$text);

      Comment

      • TCM
        Senior Member
        • Dec 2004
        • 477
        • 3.0.7

        #4
        Originally posted by tfederman
        Thanks for the tip. It looks like this does the trick:

        PHP Code:
        if ( strpos($text'<table') !== false )
        {
            
        $text str_replace('<br />'''$text);

        This should find a table anywhere in a post, and disable line breaks more efficiently (not convert them to line breaks in the first place, rather than unconverting them. :P) only if HTML is enabled.

        Location: bbcode_parse_start
        Code:
        PHP Code:
        if (preg_match("%<table[^>]*>.*</table>%si"$text) && $dohtml) {
            
        $donl2br false;

        EDIT: I just tested it and it didn't work. >.< I'll see if I can fix it.

        EDIT: Fixed and attached.
        Attached Files
        Last edited by TCM; Fri 9 Dec '05, 5:13pm.

        Comment

        • tfederman
          New Member
          • Dec 2005
          • 6
          • 3.5.x

          #5
          That's great, TCM. Much better than my quick hack. Thank you.

          Comment

          • DeXTeR27
            New Member
            • Apr 2007
            • 11
            • 3.6.x

            #6
            my apologies for interrupting this thread but im having a very similiar issue.

            First off, are you putting this is class_bbcode.php or a different file.

            second, instead of tables, how could i convert this to work for forms.

            Thanks

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...
            😀
            😂
            🥰
            😘
            🤢
            😎
            😞
            😡
            👍
            👎