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

Help with simple BBcode

cclaerhout

Well-known member
#3
Hi All, I'm trying to create a simple BBcode that will do the following:

[foobar]www.google.com[/foobar]

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?

Thanks!
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).
 

cclaerhout

Well-known member
#5
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...
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

Active member
#7
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.
 

NeoCHI

Active member
#9
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
 

cclaerhout

Well-known member
#10
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
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.
 

cclaerhout

Well-known member
#15
:cry: it's still autolinking...I've tried both disabling for both "in all content" and "just a url"...am I doing something wrong?
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.

Also, I noticed if I use any capital letters for the "BB code tag" then it breaks?
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.
 

NeoCHI

Active member
#16
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.
 

cclaerhout

Well-known member
#17
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.
The letter case of tags should not matter in posts.
Code:
[raw]test[/raw]
[RAW]<b>test</b>[/RAW]
[Raw]<b>test</b>[/Raw]
[php]test[/php]
[phP]test[/Php]
[PHP]test[/PHP]
Here is the result:
r.png
 

NeoCHI

Active member
#18
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