Jump to content


Photo

configure simple bbcode parser


  • Please log in to reply
3 replies to this topic

#1 Duc Su

Duc Su

    Young Padawan

  • Members
  • Pip
  • 29 posts

Posted 06 April 2011 - 11:07 PM

I have a php script blog website that visitors can comment on. I wish to install a simple bbcode to enhance the text. I got this how to on the net but am having trouble with the last part. It says to put this line of code

bbcode editor


<?php $parser = new bbParser();
$text = $parser->getHtml($_POST['test']);

?>


I do not know where it goes to be exact. I would imagine in the index.php where I have edit the <textarea> field. I have tried but the text doesn't parse and it still shows plain text along with , etc... Can I get some assistance please.


#2 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 07 April 2011 - 12:53 AM

Where in the php were you originally handling the post data? Basically, where ever that was, is where you need to put the new code.

If that doesn't make sense, could you post a sample of your code (not the bbParser class, but the portion where you are doing the form handling)?

#3 Duc Su

Duc Su

    Young Padawan

  • Members
  • Pip
  • 29 posts

Posted 07 April 2011 - 01:13 AM

Where in the php were you originally handling the post data? Basically, where ever that was, is where you need to put the new code.

If that doesn't make sense, could you post a sample of your code (not the bbParser class, but the portion where you are doing the form handling)?


Thanks for the reply. I got it figured out and working. My php script doesn't work with the example provided. I didn't have to do a include and new() lines in my index.php file. Since the post data was being saved to a database, I copied/paste the bbparser.php code in my functions.ini file and call it from my comment class file right before it is save to the database. When I look in the database, I can see it was been parsed to html and the comments viewed as html in the website. I am not sure if I did it correctly but it seems to work.

My other issue is that, the auto email response for each comments posted shows bbcode codes. How can I get it parse to convert it to html? I assume it is the same way as what I have done.

#4 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 07 April 2011 - 10:43 AM

My other issue is that, the auto email response for each comments posted shows bbcode codes. How can I get it parse to convert it to html? I assume it is the same way as what I have done.

It sounds like you did things correctly so yes, doing the same thing for the e-mails should work.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users