phpBBHacks.com - Making Your Custom BBCode
Talk martial arts at KarateForums.com
StatsForums Home   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in
FAQFAQ   SearchSearch   MemberlistMemberlist   TutorialsTutorials   ContactContact Us
Add Us:     MySpace     Facebook     StumbleUpon
Username:    Password:
Remember Me?    
Making Your Custom BBCode
BlinkList
del.icio.us
Furl
linkaGoGo
reddit
Simpy
Mister Wong
Yahoo! My Web

Post new topic   Reply to topic    phpBBHacks.com Support Forums Forum Index -> phpBB 2: Customizing Your phpBB
 See a User Guidelines violation? Please contact us.
Author Message

DTTVB
Not So New User

Joined: 18 Aug 2005
Posts: 45
Location: Thailand (GMT+7)

PostPosted: September 14th 2005, 7:08 pm    Post subject: Making Your Custom BBCode Reply with quote

Well, this tutorial will show how to make custom BBCodes

First, open PHPBB Root Path\includes\bbcode.php

You will find these:
Code:
function bbencode_first_pass($text, $uid)
{
   // pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
   // This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.
   $text = " " . $text;

   // [code] and [/code] for posting code (HTML, PHP, C etc etc) in your posts.
   $text = bbencode_first_pass_pda($text, $uid, '[code]', '[/code]', '', true, '');

   // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff.
   $text = bbencode_first_pass_pda($text, $uid, '[quote]', '[/quote]', '', false, '');
   $text = bbencode_first_pass_pda($text, $uid, '/\[quote=(\\\".*?\\\")\]/is', '[/quote]', '', false, '', "[quote:$uid=\\1]");

   // [list] and [list=x] for (un)ordered lists.
   $open_tag = array();
   $open_tag[0] = "[list]";

   // unordered..
   $text = bbencode_first_pass_pda($text, $uid, $open_tag, "[/list]", "[/list:u]", false, 'replace_listitems');

   $open_tag[0] = "[list=1]";
   $open_tag[1] = "[list=a]";

   // ordered.
   $text = bbencode_first_pass_pda($text, $uid, $open_tag, "[/list]", "[/list:o]",  false, 'replace_listitems');


Well let's add a new code.
BBCode must be translated and insert to database
So [b] and [/b] would be [b:0123456789] and [/b:0123456789]

No-Variable BBCode Such as [move] (Like YaBB)
We will add this:
Code:
   $text = preg_replace("#\[move\](.*?)\[/move\]#si", "[move:$uid]\\1[/move:$uid]", $text);

You will see in first agrument, we will add \ before [ and ]
But I have no idea about # and #si
Second agrument:
$uid must be placed so [move] can become [move:0123456789]
\\1 is the text.

Variable BBCode Such as [align]
Code:
   $text = preg_replace("#\[align=([a-zA-Z]+)\](.*?)\[/align\]#si", "[align=\\1:$uid]\\2[/align:$uid]", $text);

Like the first one
Second one \\1 is first agrument
\\2 is text
But if you made 2 agrument, so
\\1 is 1st agrument \\2 is second agrument
and \\3 is text

Find this
Code:
function bbencode_second_pass($text, $uid)
{
   global $lang, $bbcode_tpl;

   $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);

   // pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
   // This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.
   $text = " " . $text;

   // First: If there isn't a "[" and a "]" in the message, don't bother.
   if (! (strpos($text, "[") && strpos($text, "]")) )
   {
      // Remove padding, return.
      $text = substr($text, 1);
      return $text;
   }

   // Only load the templates ONCE..
   if (!defined("BBCODE_TPL_READY"))
   {
      // load templates from file into array.
      $bbcode_tpl = load_bbcode_template();

      // prepare array for use in regexps.
      $bbcode_tpl = prepare_bbcode_template($bbcode_tpl);
   }

   // [code] and [/code] for posting code (HTML, PHP, C etc etc) in your posts.
   $text = bbencode_second_pass_code($text, $uid, $bbcode_tpl);

   // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff.
   $text = str_replace("[quote:$uid]", $bbcode_tpl['quote_open'], $text);
   $text = str_replace("[/quote:$uid]", $bbcode_tpl['quote_close'], $text);


We must do for each open and close tag.
So... First let's see for [move]
Code:
   $text = str_replace("[move:$uid]", "<marquee>", $text);
   $text = str_replace("[/move:$uid]", "</marquee>", $text);

First one is translated BBCode [move:0123456789] and [/move:0123456789]
Second one is HTML code.

Code:
   $text = preg_replace("/\[align=([a-zA-Z]+):$uid\]/si", "<div align=\\1>", $text);
   $text = str_replace("[/align:$uid]", "</div>", $text);


Just like first one, but variables will be \\1 and \\2

Be sure to use "Double Quote"

Make your own protocol

Code:
function make_clickable($text)
{
   $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);

   // pad it with a space so we can match things at the start of the 1st line.
   $ret = ' ' . $text;

After that line we'll add a "Flash" protocol
It goes like this: flashhttp://www.and-so-on.com/myfile.swf

Well add this
Code:
   $ret = preg_replace("#(^|[\n ])flash([\w]+?://[^ \"\n\r\t<]*)\?([0-9]+)&amp;([0-9]+)#is", "\\1<embed src=\"\\2\" width=\\3 height=\\4>", $ret);


Useful Infomation http://www.php.net/preg_replace
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    phpBBHacks.com Support Forums Forum Index -> phpBB 2: Customizing Your phpBB All times are GMT - 6 Hours
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Links: Big Message Boards - Free JavaScript - phpBB2 - phpbb styles - Suporte phpBB - phpBB.it - phpBB Česky - phpBB Turkiye - phpBBArabia.com - phpBB-fr.com - Romanian phpBB online community - phpBB-TW.net - phpBBservice.nl - phpBB Brasil

Network: iFroggy Network Blog - iFroggy Hosting - SportsForums.net - KarateForums.com - YanksBlog.com - PhotoshopForums.com - DeveloperCube - Managing Online Forums - ManagingCommunities.com - CommunityAdmins.com - DrGregHouse.com - Bad Boy Blog - BadBoyForums.com - SodaRatings.com - Patrick O'Keefe

< Advertising - Contact Us - Staff - User Guidelines >

Copyright © 2001-2008. iFroggy Network, phpBBHacks.com. All Rights Reserved. Privacy Policy. We Support phpBBHacks.com (of course!).
Powered by phpBB © phpBB Group. phpBB SEO. Hosted by 100MegsWebHosting. We are in no way affiliated with the phpBB Group. phpBB is copyright to the phpBB Group.