bbCode into php site
Moderator: General Moderators
bbCode into php site
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.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
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.
- iknownothing
- Forum Contributor
- Posts: 337
- Joined: Sun Dec 17, 2006 11:53 pm
- Location: Sunshine Coast, Australia
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...
[/syntax]
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>