Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

I am wanting to add a particular button.

edited December 2011 in Vanilla 2.0 - 2.8

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 Operations 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.

    Vanilla Forums COO [GitHub, Twitter, About.me]

Answers

  • edited May 2012

    I keep getting notified that I have an answer and should accept it if correct. I come here and only see my post. Heh.

  • TimTim Operations 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.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • Hey sorry that question was old and silly. I couldn't modify it. Yeah it's terribly easy to add buttons to this plugin. Thanks for responding though, so I can finally mark this answered and end the jquery notifications.

Sign In or Register to comment.