I'm looking for you guys' experiance with making BB code. I got everything up and running great except I've been having a lot of problems trying to get my links to work correctly.

I'm wondering how you guys do it.

I'm wanting to take something like:

[hyperlink=http://www.ndgamers.com]NDGamers[/hyperlink]

To turn out like:
NDGamers

Thoughts?

    Attached to this post is a function I wrote for formatting bbcode on one of my webpages.

      that's a GREAT function. How do you do the opposite if someone needs to edit the post?

        would it work if I stored the string in the database unedited, then when posting it, it would show the new, edited code?

          The way I wrote it was like this:

          1) User wrote news to be posted on the website and formatted it with any bbcode he or she wanted to use.

          2) I stored the string in the database unformatted (i.e. it still had it's bbcode in the text, not it's HTML/CSS equivalent.).

          3) When viewing news on the main page, I just ran tagformat($row['text']) (or whatever the field was called), and it formatted the text after pulling it from the database.

          So, if the user needed to edit the content afterwards, I would just pull the bbcode formatted entry from the database and stick it into a textarea field. Then they could edit it from there and their changes would show up.

          Hopefully that made sense. 😉

            That's exactlty what I ended up doing. Thanks again so much!

              5 months later

              Just found this thread, that function is gonna save me a lotta time figuring out the regexs myself, thanks rheroux! 🙂

                Write a Reply...