Welcome to WebmasterWorld Guest from 107.20.104.110

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Best place to decode bbcode

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

Full Member

10+ Year Member

joined:Mar 17, 2004
posts:215
votes: 0


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)

Senior Member

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

joined:Nov 12, 2005
posts:5966
votes: 0


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)

Full Member

10+ Year Member

joined:Mar 17, 2004
posts:215
votes: 0


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)

Junior Member

10+ Year Member

joined:Nov 22, 2005
posts:152
votes: 0


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 22, 2002
posts:1749
votes: 0


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?

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members