Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

BBInsertBar: how to add a new button

edited December 2006 in Vanilla 1.0 Help
I have added YouTube support to my forum as in this post: Now I would like to add a button or some kind of link to the posting area, so people can easily embed their videos. Can anyone advise?


  • circuit, I just (quickly) read through the linked post and from that post it looks like you didn't succeed in doing it. Please post the code in here that you actually used to enable it. (wrap it in <code></code> tags)
  • I added the following (below), it all works fine, not sure why you say I didn't succeed?? I can embed videos using [ youtube ] tags, i just want a toolbar button for it.

    function Parse($String, $Object, $FormatPurpose) { $parser = new HTML_BBCodeParser(); if ($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) { $String = $this->ProtectString($String); $String = $parser->qparse($String); $String = preg_replace('/\<youtube\>(.+?)\<\/youtube\>/', '<object width="425" height="350"><param name="movie" value="$1"></param><embed src="$1" type="application/x-shockwave-flash" width="425" height="350"></embed></object>', $String); return $String; } else return $String; }


    'youtube' => array( 'htmlopen' => 'youtube', 'htmlclose' => 'youtube', 'allowed' => 'all', 'attributes'=> array()),
  • StashStash
    edited December 2006
    And please give me an example of what you would type in an actual comment to get a video to show up in a post. Something worksafe if you don't mind ;) I'm just trying to get the mod to work before I can try to give you a button :)
  • oh sure

    [ youtube ] (videoID) [ /youtube ]

    without the spaces of course :) ...where the video ID is the bit at the end of a youtube link.
  • Hmm, that's what I tried and it didn't work *sigh*
    All it did for me was display the video ID as plain text...

    I used:
    Does that work for you?
  • yeah, that works fine for me. did you actually replace the parse() function in default PHP? not just add the code to the file. that's all i can think of that could be wrong.
  • Yeah, did that, nothin'. Perhaps you could just zip up your BetterBBCode extension and let me download it? Would probably be easier no? :)
  • i will do - it may be later on/tomorrow but i'll reply when i've done it.
  • image -> extensions/BBInsertBar/buttons

    After line 32ish$Context->Dictionary['bbsmilie'] = 'Insert Smilie';Add, do NOT replace!$Context->Dictionary['bbyoutube'] = 'Insert YouTube Video';
    After line 67ish if ($this->Context->Configuration["BBBAR_DISABLE_VANILLACONS_BAR"] == TRUE) echo "<a onclick=\"insertBBSmilie()\"><img src='".$this->Context->Configuration["BASE_URL"].$this->Context->Configuration["BBBAR_PATH"]."buttons/text_smilies.gif' alt='".$this->Context->GetDefinition('bbsmilie')."' title='".$this->Context->GetDefinition('bbsmilie')."' /></a>";Add, do NOT replace! echo "<a onclick=\"insert('youtube','/youtube','".$this->Context->Configuration["BBBAR_DISABLE_VANILLACONS_BAR"]."')\"><img src='".$this->Context->Configuration["BASE_URL"].$this->Context->Configuration["BBBAR_PATH"]."buttons/text_youtube.gif' alt='".$this->Context->GetDefinition('bbyoutube')."' title='".$this->Context->GetDefinition('bbyoutube')."' /></a>";
    I think that just about covers it, but as I haven't got this working my end and I can't code PHP or JS yet, I'm shooting in the dark.

    P.S. I still want that ZIP file you know, I want this to work for me and all ;)
  • edited December 2006
    i'll definitely get it to you! the button works great, thank you! would it be easy to add a javascript prompt asking for the video ID? i don't know much javascript at all. am i being really silly and demanding now? thanks for doing that, i really appreciate it!
  • Well you can currently paste in the YouTube vidID, select it and hit the button, or hit the button then hit paste ;) I doubt it would be too hard to add a dialogue box with a little bit of explanatory text, I assume you'd just have to abuse the code for the picture, link or email code...

    Anyway, it's 0126 and I have work later at 0900 so that's not a job for now but later :P zzzzzzzZZZZZZZZzzzzzzzzzzzzzzzzzzzzz
This discussion has been closed.