1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with simple BBcode

Discussion in 'XenForo Questions and Support' started by NeoCHI, Mar 27, 2013.

  1. NeoCHI

    NeoCHI Active Member

    Hi All, I'm trying to create a simple BBcode that will do the following:


    replaces this with:

    <div class = "foobar">www.google.com</div>

    The end result would be an actual div not the above text.

    Can someone help me with the simplest step by step way to get this done?

  2. Brogan

    Brogan XenForo Moderator Staff Member

    Simple Replacement Start: <div class = "foobar">

    Simple Replacement End: </div>
  3. cclaerhout

    cclaerhout Well-Known Member

    If you use an URL in the content, you will also need to disable the autolinking inside the options of the BbCode. For this you will need to use a recent version of the Bbcm (see here for the last version).
  4. NeoCHI

    NeoCHI Active Member

    Sorry but im a total noob. Can you break this down a bit more? Hopefully step by step?

    Basically i dont even know where to start to make a bbcode...
  5. cclaerhout

    cclaerhout Well-Known Member

    XenForo doesn't have a manager to create/edit Bb Codes yet, so you need the "Bbcm" (Custom BB Code Manager). If you need to use an url as content of your Bb Code, you need to install a recent version of the Bbcm (see here) ; otherwise the XenForo autolinking function will "corrupt" your Bb Code and will break it.

    • Download and install the Bbcm
    • Go to AdminCp (Home) - Click on BB Code Manager => Create a new Bb Code
    • To create a Bb Code, you have three methods to parse your Bb Code:
      1. direct replacements (the one Brogan shows you)
      2. the template method (can be easy or advanced)
      3. the php callback method (the most difficult)
      If you need a basic replacement, go for the first one
    • Then go to the parser configuration to disable the autolinking

    There are many example of Bb Codes in the extras directory of the archive using all the three methods. Try to look how they work.
    NeoCHI likes this.
  6. NeoCHI

    NeoCHI Active Member

    Great thanks!
  7. NeoCHI

    NeoCHI Active Member

    I got most of it working but I couldn't find where to disable the autolinking.

    Within the parsing options I could only find the following:

    • Do not parse BB Codes placed within this BB Code.
    • Do not parse smilies within this BB Code.
    • Stop conversion of line breaks to HTML line breaks.
    None of those helped with autolinking.
  8. NeoCHI

    NeoCHI Active Member

    Nvm looks like I didn't download the latest version as you mentioned.
  9. NeoCHI

    NeoCHI Active Member

    I'm getting the following error whenever I click into a post now:

    Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in/home/hello/public_html/foobar.com/library/KingK/BbCodeManager/BbCode/Formatter/Base.php on line 872
  10. cclaerhout

    cclaerhout Well-Known Member

    You're using PHP 5.2 or under. Here is the reason. Can't you update your php to 5.3 ?
    => I will check a fix if needed.
    Edit: I've tested a fix and it works. I will publish an update.
  11. cclaerhout

    cclaerhout Well-Known Member

    Fix for php 5.2 is here.
    Taxi and NeoCHI like this.
  12. NeoCHI

    NeoCHI Active Member

    Your awesome! Im going to name my first son after u!
  13. NeoCHI

    NeoCHI Active Member

    :cry: it's still autolinking...I've tried both disabling for both "in all content" and "just a url"...am I doing something wrong?
  14. NeoCHI

    NeoCHI Active Member

    Also, I noticed if I use any capital letters for the "BB code tag" then it breaks?
  15. cclaerhout

    cclaerhout Well-Known Member

    Can you test one of this Bb Codes:
    See the demo here to see how to use them.

    If it's working for you, then it's a problem with your code. If it doesn't it should come from my code but quite a few members use it here and it seems it works fine. May be again a php 5.2 problem, but this time I don't see where it could come from.

    It doesn't for me. Where do you have this problem? When you try to rename it (through the admin interface) or use it (in messages)? If it's a rename problem in the admin interface (capital letters to lower case), just give him a temporary name and rename it after. In messages, case doesn't matter.
  16. NeoCHI

    NeoCHI Active Member

    Ahhh I think I know what i did wrong now....when I was testing it I copied and pasted a already autolinked link from previous post and that carried over into the tag.

    As for the capital letters it's not when I rename or when I use it in messages. It's when I create a new bb code and I use capital letters for the "BB code tag". I've also noticed all the bbcode you've created used all lower cased names so it doesn't have that problem. Thing is default bbcode are in all caps I just wanted to keep with that style.
  17. cclaerhout

    cclaerhout Well-Known Member

    The letter case of tags should not matter in posts.
    Here is the result:
  18. NeoCHI

    NeoCHI Active Member

    icic, well the issue I was experiencing was actually when naming the bb code tag within the admin cp. I guess it's nice to know that when using it, it's case insensitive. Although my anal side makes me bothered by the fact that within the examples page the bbcode will be in lowercase while all the default bbcodes are in all uppercase but I guess that's not a big deal :p

Share This Page