Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - No more br tags in the database mod
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

No more br tags in the database mod

 Post Reply Post Reply
Author
Sumea View Drop Down
Newbie
Newbie


Joined: 18 September 2006
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sumea Quote  Post ReplyReply Direct Link To This Post Topic: No more br tags in the database mod
    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.


Edited by Sumea - 26 September 2006 at 10:31pm
Back to Top
Imperator View Drop Down
Newbie
Newbie


Joined: 02 October 2004
Status: Offline
Points: 39
Post Options Post Options   Thanks (0) Thanks(0)   Quote Imperator Quote  Post ReplyReply Direct Link To This Post Posted: 22 September 2006 at 6:41pm
That's an interesting mod you have there.
Back to Top
Frans View Drop Down
Newbie
Newbie


Joined: 09 November 2006
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote Frans Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.