bbCode into php site

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
trassalg
Forum Newbie
Posts: 23
Joined: Fri Jul 27, 2007 3:26 pm

bbCode into php site

Post by trassalg »

Can anyone recommend a simple way of implementing bbcode into a php-based website/database design? I'd like the user to be able to enter the data using bbcode's options (simple click and format options without having to know anything about code... like this site has) and have this display in pages when the results are pulled out of the database and displayed in HTML format.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Simple? You are asking for both bbCode parsing and JavaScript-controlled entry into the textarea.

Is there any one part in particular that you are after?
trassalg
Forum Newbie
Posts: 23
Joined: Fri Jul 27, 2007 3:26 pm

Post by trassalg »

Was wondering what the "standard" way of going about this would be from others with more experience in it. I'm pretty much clueless as to what tools I'd need to implement to do so, but know there are quite a few open source bbcode projects out there. Just didn't know if there was a fairly user friendly version.
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Post by iknownothing »

on a quick search I found this:

http://pear.php.net/package/HTML_BBCodeParser

Didn't look much into it, but it appears to be something like what you are looking for.

If it is not, then I think that all the code translations will have to be done yourself using string replace functions and the like with PHP.


I believe that the click buttons you mentioned, assuming you mean (Bold, Italic, Underline etc) do not come with this, and forums such as this one have had the various buttons coded into them, with use of Javascript.

For example, 100% completely untested...

Code: Select all


function doBold() {
var OnOffBold;

if (OnOffBold = "0"){
thetext.innerHTML += '[b]';
OnOffBold = "1"
}

if (OnOffBold = "1"){
thetext.innerHTML += '[/b]';
OnOffBold = "0"
}

}

Code: Select all

//BOLD Button
<input type="button" name="bold" value="B" onclick="doBold();">
<textarea name="thetext"></textarea>
[/syntax]
Post Reply