Print Page | Close Window

No more br tags in the database mod

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums Modifications
Forum Description: Mod's and Add-on's for Web Wiz Forums.
URL: https://forums.webwiz.net/forum_posts.asp?TID=21361
Printed Date: 29 March 2026 at 10:57pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: No more br tags in the database mod
Posted By: Sumea
Subject: No more br tags in the database mod
Date Posted: 21 September 2006 at 7:17pm
Ok, I've switched over from Snitz forum to WWF, and I noticed that all the posts made under Snitz (thousands of them) weren't formatted properly, and the new posts made with WWF were. I looked into what WWF is putting into the dababase, and saw that it's replacing all carriage returns with <br/> tags to show paragraphs and linebreaks in the messages that are posted.

This isn't really necessary when you could use css to preserve white space in messages. To sum up what this is doing is that it's changing the css style to preserve white space for messages, and to stop WWF from putting in all those <br/> tags into the database. In the long run, it'll keep your database a little slimmer.
The only other option for me to keep a consistency was to replace all the carriage returns in the database with <br/> tags.. not exactly ideal. So this way is much better.

If you're going to implement this, and you're not coming from Snitz and have already lots of messages on your forum, you'll have to do a sql query to search and replace on your database to remove all the <br/> tags in the threads. It might not even be worth implementing for you really.
If you've migrated your Snitz forum to WWF or if you're just starting a wwf forum and you know what you're doing, then this mod will definately be useful.

1: in your default_style.css stylesheets

-- include:

.PMmsgBody, .msgBody{
    white-space: pre-wrap;       /* css-3 should we be so lucky... */
    white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
    white-space: -pre-wrap;      /* Opera 4-6 ?? */
    white-space: -o-pre-wrap;    /* Opera 7 ?? */
    word-wrap: break-word;       /* Internet Explorer 5.5+ */
    _white-space: pre;   /* IE only hack to re-specify in addition to word-wrap  */
}

2: functions/functions_format_post.asp , line 127

-- find:

strMessage = Replace(strMessage, Chr(10), "<br />", 1, -1, 1)

-- and remove it. The break tags won't be put into the database now.


3: forum_posts.asp , line 918

change:

   <!-- Start Member Post -->
   <div class="msgBody" style="float:left; overflow:auto;">
   <% = strMessage %>

to:

   <!-- Start Member Post -->
   <div class="msgBody" style="float:left; overflow:auto;"><% = strMessage %>
   </div>

-- Why do we do this? There are four spaces which needs to be removed between the msgBody class tag and the message.  Because our stylesheet "msgBody" shows all the white space between the the div, it'll show those spaces as well. You don't want 4 spaces at the beginning of every post.


4: RTE_popup_preview.asp , line 159

change:

<% = strPreviewTextarea %>

to:

<div class="msgBody"><% = strPreviewTextarea %></div>

-- this is so that when you preview your posts, they get displayed correctly as well.

5.  printer_friendly_posts.asp

find the table around line 348 (it's hard to miss it!) and change it to:

      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><div class="msgBody"><%  Response.Write("    <!-- Message body -->" & vbCrLf & strMessage & vbCrLf &  "<!-- Message body ''"""" -->") %></div></td>
        </tr>
       </table>

and also the table around line 411 to:

      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><div class="msgBody"><%  Response.Write("    <!-- Message body -->" & vbCrLf & strMessage & vbCrLf &  "<!-- Message body ''"""" -->") %></div></td>
        </tr>
       </table>

-- this is so that when someone views the printer friendly version, it looks correct there.



Replies:
Posted By: Imperator
Date Posted: 22 September 2006 at 6:41pm
That's an interesting mod you have there.


Posted By: Frans
Date Posted: 09 November 2006 at 11:36am
chr(10) is that not linefeed ?
 
Maybe its an idea to add the conversion to the convert.asp script? or use update tblthread set message=replace(message,chr(10),"<br/>")
 
Nice work on the snitz conversion Clap



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net