Custom BBCodes [Deprecated]

Get help developing custom BBCodes or request one.
User avatar
Terr0r
Registered User
Posts: 553
Joined: Thu May 05, 2011 3:39 pm
Location: The Netherlands

Re: phpBB how to embed Megavideo.com

Post by Terr0r »

dobegarios wrote:Hello guys how are you

i was trying to embed Megavideo,

so i need a little help to make it

thanks
Megavideo bbcode

BBCode usage

Code: Select all

[megavideo]http://www.megavideo.com/?v={SIMPLETEXT}[/megavideo]
HTML replacement

Code: Select all

<object width="450" height="343"><param name="movie" value="http://www.megavideo.com/v/{SIMPLETEXT}"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.megavideo.com/v/{SIMPLETEXT}" type="application/x-shockwave-flash" allowfullscreen="true" width="450" height="343"></embed></object>
Help line

Code: Select all

[megavideo]video url[/megavideo]
Greets Terr0r
if you can't fix it with ducktape you ain't using enough
if you want to search a MOD maybe you can find it here
For my MODS and BBCodes or other things that I have made take a look here
Bash
Registered User
Posts: 337
Joined: Wed Mar 11, 2009 3:36 pm
Location: London, England
Name: Glenn

Re: Custom BBCodes

Post by Bash »

Thank you Terror, you're a beautiful man :D

Much love.
centerpin
Registered User
Posts: 9
Joined: Thu Nov 10, 2011 7:46 pm

Re: Custom BBCodes

Post by centerpin »

centerpin wrote:I know there is a bunch of bbcode info but me being the designer guy than the code guy my knowledge of code only goes so far.

I was wondering if someone would be willing to point me in the right direction on how to make this bbcode work correctly in my forums. I'm not asking someone to do it for me, I would like to learn on how to do these on my own.

this is what I'm trying to work out. The custom one at the bottom of that page.
http://db.darthhater.com/syndication.aspx

I would like it be able to have it like this [swdb]{insert url here}[/swdb] when someone goes to use this function.

Any help would be greatly appreciated. :D

anyone?
Pony99CA
Registered User
Posts: 4783
Joined: Thu Sep 30, 2004 3:13 pm
Location: Hollister, CA
Name: Steve

Re: Template Variables in BBCodes

Post by Pony99CA »

StuButler wrote:I'd like to pull {postrow.POST_ID} and {postrow.POST_AUTHOR_FULL} to use as part of a BBCode. Any suggestions on how i would go about doing this?
As far as I know, there's no way to get template variables into BBCodes. It's a cool idea, though (and I seem to recall somebody else asking about it recently).

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.
User avatar
AmigoJack
Registered User
Posts: 6128
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン

Re: Custom BBCodes

Post by AmigoJack »

StuButler wrote:I'd like to pull {postrow.POST_ID} and {postrow.POST_AUTHOR_FULL} to use as part of a BBCode
Both details are already attached to each post when viewing it, so I conclude you want to so something redundant (which makes little sense). In theory, you could solve it with JS, but I'd need a precise example of what you want to achieve so I'm not starting at the wrong point.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
sebastos.pl
Registered User
Posts: 39
Joined: Wed Sep 21, 2011 9:46 pm

Re: Custom BBCodes

Post by sebastos.pl »

anyone can help me with this?

Code: Select all

<div class="haudio">
<li class="item">
<span class="contributor">
<span class="vcard">
<a class="url fn org" href="http://www.myspace.com/herbiehancock">Herbie Hancock</a></span> - <span class="title">Chameleon</span>
</span>
</li>
</div>
http://www.gettomahawk.com/blog/tips_tricks/haudio

I tried with this:

Code: Select all

[listen={URL}]{SIMPLETEXT1} - {SIMPLETEXT2)[/listen]

Code: Select all

<div class="haudio">
<li class="item">
<span class="contributor">
<span class="vcard">
<a class="url fn org" href="{URL}">{SIMPLETEXT2}</a></span> - <span class="title">{SIMPLETEXT1)</span>
</span>
</li>
</div>
but it don't work. I see:

Code: Select all

[listen=www.lastfm.pl/music/Gotye]SOMEBODY THAT I USED TO KNOW - Gotye[/listen]
StuButler
Registered User
Posts: 8
Joined: Tue Aug 02, 2011 10:19 am

Re: Custom BBCodes

Post by StuButler »

AmigoJack wrote:
StuButler wrote:I'd like to pull {postrow.POST_ID} and {postrow.POST_AUTHOR_FULL} to use as part of a BBCode
Both details are already attached to each post when viewing it, so I conclude you want to so something redundant (which makes little sense). In theory, you could solve it with JS, but I'd need a precise example of what you want to achieve so I'm not starting at the wrong point.
I'm using a lightbox system for a custom image handling tag, i'd like to be able to either group images by author or post.

Lighbox has the option of putting a specific element in square brackets to identify the grouping. I don't want this to be something that users have to input themselves.

Does that help?
User avatar
AmigoJack
Registered User
Posts: 6128
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン

Re: Custom BBCodes

Post by AmigoJack »

StuButler wrote:a lightbox system
So you're already using JS. I did this once for Highslide.

However, to have the post ID and/or user ID available in a custom BBCode there is a rather q+d approach. Open /includes/bbcode.php and find:

Code: Select all

                    if (sizeof($str['search']))
                    { 
Before, add:

Code: Select all

                    /*** 2012-01-31 BEGIN AmigoJack
                        Provide post ID and user ID to custom BBCodes ***/
                    if( count( $str['search'] )&& count( $str['replace']== 1 ) ) $pType= 'str'; else
                    if( count( $preg['search'] )&& count( $preg['replace']== 1 ) ) $pType= 'preg'; else
                    $pType= '';

                    if( $pType ) {  // Custom BBCodes only have one replacement
                        global $row;  // Obviously this only works for viewtopic.php

                        ${$pType}['replace'][0]= str_replace
                        ( array
                            ( '{POST}'  // Hardcoded tokens to be used in the BBCode replacement
                            , '{USER}'  // You could add more, of course...
                            )
                        , array
                            ( isset( $row['post_id'] )? $row['post_id']: 0  // ...replaced with the current value
                            , isset( $row['user_id'] )? $row['user_id']: 0
                            )
                        , ${$pType}['replace'][0] 
                        );
                    }
                    /*** 2012-01-31 END ***/ 
That's it. Now you can create your custom BBCodes with the BBCode usage of anything, i.e.: [thispost][/thispost] and a HTML replacement which contains i.e. the text {POST}.

You can use the token {USER} in the same manner. Or use both in one replacement.

Tested.
Last edited by AmigoJack on Tue Jan 31, 2012 11:57 am, edited 2 times in total.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
StuButler
Registered User
Posts: 8
Joined: Tue Aug 02, 2011 10:19 am

Re: Custom BBCodes

Post by StuButler »

Awesome, I'll give that a go asap. Thanks!
User avatar
Rotten Apple
Registered User
Posts: 211
Joined: Wed Oct 06, 2010 2:27 am
Location: Florida, USA
Name: Vicky

Re: Custom BBCodes

Post by Rotten Apple »

I want to turn this code into a BBCode. Is something like this possible? I’ve tried doing it myself, but it won’t work. :\ It works fine when it's a normal HTML doc, but that's not what I want. Assistance with this is greatly appreciated!
User avatar
AmigoJack
Registered User
Posts: 6128
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン

Re: Custom BBCodes

Post by AmigoJack »

Rotten Apple wrote:this code
That would only work once, so you can't have it multiple times in one post or multiple posts with that code on the same page. Also it's one of those functionalities which are suboptimal for being used as a custom BBCode only. Do you still want it?
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
User avatar
Rotten Apple
Registered User
Posts: 211
Joined: Wed Oct 06, 2010 2:27 am
Location: Florida, USA
Name: Vicky

Re: Custom BBCodes

Post by Rotten Apple »

Sure do! I plan on using it for admin topics anyway where it'll only be used once.
User avatar
AmigoJack
Registered User
Posts: 6128
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン

Re: Custom BBCodes

Post by AmigoJack »

BBCode usage:

Code: Select all

[triptych]{TEXT1}|{TEXT2}|{TEXT3}|{TEXT4}|{TEXT5}|{TEXT6}[/triptych]
HTML replacement:

Code: Select all

<script type="text/javascript">
  document.write
  ( '<style type="text/css"> '
  + '.detail { float: left; display: none; } '
  + '#triggers div { cursor: pointer; float: left; padding: 5px 2px; border-right: 1px solid brown; border-left: 1px solid brown; } '
  + '<\/style>' );

  function reveal( det ) {
    if( !document.getElementsByClassName ) {
      document.getElementsByClassName= function( cn ) {
        cn= cn.replace( / +/g, ' ' ).split( ' ' );
        var ar= [], testname= function( n ) {
          for( var re, i= cn.length- 1; i> -1; --i ) {
            re= new RegExp( '(^|\W)'+ cn[i]+ '(\W|$)' );
            if( !re.test( n ) ) return false;
          }
          return true;
        }
        for( var d= document.all|| document.getElementsByTagName( '*' ), i= 0; i< d.length; ++i )
        if( testname( d[i].className ) ) ar[ar.length]= d[i];
        return ar;
      };
      document.getElementsByClassName.spoof= true;
    }
    for( var d= document.getElementsByClassName( 'detail' ), i= d.length- 1; i> -1; --i )
    d[i].style.display= 'none';
    document.getElementById( det ).style.display= 'block';
    if( document.getElementsByClassName.spoof )
    document.getElementsByClassName.spoof= document.getElementsByClassName= null;
  }
</script>
<div id="triggers" style="float: left; border: 1px solid #ccc">
  <div onclick="reveal('first');">{TEXT1}</div>
  <div onclick="reveal('second');">{TEXT2}</div>
  <div onclick="reveal('third');">{TEXT3}</div>
</div>
<div class="detail" style="color: blue" id="first">{TEXT4}</div>
<div class="detail" style="color: green" id="second">{TEXT5}</div>
<div class="detail" style="color: #a52a2a" id="third">{TEXT6}</div>
Tested it successfully using Opera 11.52 and this text in a post:

Code: Select all

[triptych]Show hint 1
(with linebreak)|Show hint 2|Show hint 3|First hint: it is above.|Second hint: sometimes it leaks.
(with linebreak [b]and bold[/b])|Third hint: Sometimes it burns.[/triptych]
Do you understand how it works? 6 parameters, separated by a pipe | character. First 3 parameters are the "button" captions, the other 3 parameters are the texts to appear for each "button".
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
User avatar
Rotten Apple
Registered User
Posts: 211
Joined: Wed Oct 06, 2010 2:27 am
Location: Florida, USA
Name: Vicky

Re: Custom BBCodes

Post by Rotten Apple »

That works wonderfully. (Tested it in Firefox.) Thank you so much!
hudick
Registered User
Posts: 10
Joined: Mon Apr 12, 2010 3:36 pm

Re: Custom BBCodes

Post by hudick »

Hey! I have a problem with my youtube BBcode. I accidentally deleted my youtube BBcode and so i had to create a new one. It's exactly the same as previous one. But the new BBcode doesn't work in all old posts. It works fine in new posts though.

Is there any other way than STK reparse BBcode?

Return to “Custom BBCode Development and Requests”