homepage Welcome to WebmasterWorld Guest from 54.161.190.9
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Best place to decode bbcode
sned




msg:3576118
 7:53 pm on Feb 15, 2008 (gmt 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

 

eelixduppy




msg:3576162
 8:50 pm on Feb 15, 2008 (gmt 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.

sned




msg:3576263
 10:42 pm on Feb 15, 2008 (gmt 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?

Mohamed




msg:3576556
 9:43 am on Feb 16, 2008 (gmt 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]

RonPK




msg:3577178
 1:09 pm on Feb 17, 2008 (gmt 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?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved