Fork me on GitHub
Current releases are 2.1 (gold) and 2.0.18.11 (security patch for 2.0)
Ready for 2.1? Find out if your favorite plugins are compatible.
The 2.0 branch will no longer receive updates after Dec 2014.

I am wanting to add a particular button.

edited December 2011 in Vanilla 2.0 Help
This discussion is related to the Button Bar addon.

I sort of accomplished this on NBBC but I never got to truly do what I was hoping for (that being part 2).

Maybe you can point me in the right direction, unless it's something you could think up in 5 seconds and decide to post the code.

If I wanted a button that would, for example:

[card]Rewind[/card]

And on the HTML side it does:

<a href="http://magiccards.info/query?q=Rewind">Rewind</a>

What current button does something similar that I can sort of borrow the concept from? I thought that URL would be similar enough, but while playing around I couldn't quite figure out how to get it working.

I mean similar to the URL in the sense it takes what is between the BBCode and uses it as a url, but I'm not quite sure how to add it to a preexisting string. Like, the preexisting string would be http://magiccards.info/query?q=.

The second thing I'm trying to get done is a way to group a list of cards, so it'd have to do the same as above but for each new line within the tags. Something like:

[cards]Rewind
Animate Dead
Duress[/cards]

I don't think there is a current BBCode or Markdown case switch that actually does something to each individual line, is there?

Best Answer

  • TimTim Lord of Servers Vanilla Staff
    edited May 2012 Answer ✓

    Button Bar is not currently very easy to extend without modifying the core files. However, if you feel up to it you can do just that.

    Modify views/buttonbar.php

    echo '<span class="ButtonWrap"><span>card</span></span>';

    Modify js/buttonbar.js

    Add a handler for the 'card' event. At line 361:

    bbcodeOpts = {
            opener: '[',
            closer: ']'
         }
         switch (Operation) {
            case 'bold':
               $(TextArea).insertRoundTag('b',bbcodeOpts);
               break;
            case 'card':
               $(TextArea).insertRoundTag('card',bbcodeOpts);
               break;
    ...
    

    Button Bar relies on Garden's formatters to handle rendering within comments, so you would need to mess with the NBBC plugin to make it handle the rendering side, and that's something beyond the scope of this help.

Answers

Sign In or Register to comment.