Welcome to WebmasterWorld Guest from 54.225.31.78

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Best place to decode bbcode

     
7:53 pm on Feb 15, 2008 (gmt 0)

10+ Year Member



I'm curious about people's opinions on where in code to do the actual preg_replace that turns bbcode back into html code.

For example, I have a few fields in a database that store text and bbcode. Right now, I call my bb_decode function anytime I want to display that text on a page (which means the function is scattered all over the place).

Is this how webmasterworld does this kind of thing? Or are there other ways to this?

Thanks!
-sned

8:50 pm on Feb 15, 2008 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



There is less processing if you replace the bbcode with its html counterpart before you add it to the database. This way you only need to do it once.
10:42 pm on Feb 15, 2008 (gmt 0)

10+ Year Member



I've thought about decoding it before it's entered into the database, then do you just recode the text back to bbcode if the user wants to edit their text and re-submit?
9:43 am on Feb 16, 2008 (gmt 0)

5+ Year Member



You can parse and replace bbcode on fly before you display the page though it requires more processing than the other methods.

[edited by: Mohamed at 9:48 am (utc) on Feb. 16, 2008]

1:09 pm on Feb 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Right now, I call my bb_decode function anytime I want to display that text on a page (which means the function is scattered all over the place).

If that is the issue, why not put the function in a file which can then be include()d everywhere?

 

Featured Threads

Hot Threads This Week

Hot Threads This Month