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.

Trying to add a "header" button to Button Bar 1.6

DoyceTDoyceT Model Questioner ✭✭✭
edited August 2014 in Vanilla 2.0 - 2.8

Hi all,

Running 2.1.1, button bar 1.6, Markdown input format.

I'd like to add a header button, and after digging through this related post, did the following:

First: Modified the end of /plugins/NewButtonBar/design/buttonbar.css to read:

.ButtonBar .ButtonBarBold { background-position: 0px 0px; }
.ButtonBar .ButtonBarItalic { background-position: 0px -24px; }
.ButtonBar .ButtonBarHeader { background-position: 0px -48px; }
/** .ButtonBar .ButtonBarUnderline { background-position: 0px -48px; } */
.ButtonBar .ButtonBarStrike { background-position: 0px -72px; }
.ButtonBar .ButtonBarCode { background-position: 0px -96px; }
.ButtonBar .ButtonBarImage { background-position: 0px -120px; }
.ButtonBar .ButtonBarUrl { background-position: 0px -144px; }
.ButtonBar .ButtonBarQuote { background-position: 0px -168px; }
.ButtonBar .ButtonBarSpoiler { background-position: 0px -192px; }

(Underline is disabled for Markdown, so I just used the underline values.)

Second: Added a header.png to /plugins/NewButtonBar/design/images/

Third: Added a few lines to /plugins/NewButtonBar/js/buttonbar.js...

case 'header':
               $(TextArea).insertRoundTag('##',markdownOpts);
               break;

This is around line 565, in the PerformMarkdown function.

(I also added a similar set of lines under PerformHtml (for h2), just for the heck of it.)

The problem: after enabling the plugin (I remembered this time :open_mouth: ), the header button does not appear on the toolbar. Feels like I missed a step somewhere.

Comments

  • hgtonighthgtonight ∞ · New Moderator

    You need to modify the view to spit out the button markup. Should be in /plugins/ButtonBar/views/buttonbar.php.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • DoyceTDoyceT Model Questioner ✭✭✭

    Ahh. I forgot to mention that. Here it is:

    <div class="ButtonBar">
       <div class="BarWrap"><?php
          echo '<span class="ButtonWrap"><span>bold</span></span>';
          echo '<span class="ButtonWrap"><span>italic</span></span>';
          echo '<span class="ButtonWrap"><span>header</span></span>';
          echo '<span class="ButtonWrap"><span>underline</span></span>';
          echo '<span class="ButtonWrap"><span>strike</span></span>';
          echo '<span class="ButtonWrap"><span>code</span></span>';
          echo '<span class="ButtonWrap"><span>image</span></span>';
          echo '<span class="ButtonWrap"><span>url</span></span>';
          echo '<span class="ButtonWrap"><span>quote</span></span>';
          echo '<span class="ButtonWrap"><span>spoiler</span></span>';
       ?></div>
    </div>
    
  • I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited August 2014

    .> @DoyceT said:

    Ahh. I forgot to mention that. Here it is:

    <div class="ButtonBar">
       <div class="BarWrap"><?php
          echo '<span class="ButtonWrap"><span>bold</span></span>';
          echo '<span class="ButtonWrap"><span>italic</span></span>';
          echo '<span class="ButtonWrap"><span>header</span></span>';
          echo '<span class="ButtonWrap"><span>underline</span></span>';
          echo '<span class="ButtonWrap"><span>strike</span></span>';
          echo '<span class="ButtonWrap"><span>code</span></span>';
          echo '<span class="ButtonWrap"><span>image</span></span>';
          echo '<span class="ButtonWrap"><span>url</span></span>';
          echo '<span class="ButtonWrap"><span>quote</span></span>';
          echo '<span class="ButtonWrap"><span>spoiler</span></span>';
       ?></div>
    </div>
    

    you left crucial information out. what is the name of this file.

    if it is buttonbar.php, it will most likely read the view in

    https://github.com/vanilla/vanilla/blob/2.1/plugins/ButtonBar/views/buttonbar.php
    it doesn't matter if the old buttonbar is disabled, it will most likely read the wrong view if you have duplicate files, if you don't specify exactly what folder to look in, which is not always done.

    not in NewButtonBar/views/buttonbar.php

    but in buttonbar case $View = Gdn::Controller()->FetchView('buttonbar','','plugins/ButtonBar');

    https://github.com/vanilla/vanilla/blob/2.1/plugins/ButtonBar/class.buttonbar.plugin.php#L95

    whereas some plugins use this
    $view = $this->GetView('blahblah.php');

    which finds the first view it can find.

    did you make sure to change the classes in your new plugin and rename all the files, and zip up the old plugin (in case you didn't name everything correctly), so it doesn't look at the wrong view

    In cloning buttonbars you need to rename all code and files properly if you want it to work correctly.

    see ....http://vanillaforums.org/discussion/comment/213960/#Comment_213960

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • DoyceTDoyceT Model Questioner ✭✭✭

    Ahh. Thank you. Let me see if that sorts it.

  • DoyceTDoyceT Model Questioner ✭✭✭

    Yep, that got it sorted out - somewhere it must have still been pointing at the old version of Button Bar. Once I got that out of the way (and edited the sprites.png), it worked!

Sign In or Register to comment.