[RC1] Center BBcode

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Amezis
Registered User
Posts: 116
Joined: Sun Jul 24, 2005 9:10 am
Location: Oslo, Norway
Contact:

[RC1] Center BBcode

Post by Amezis » Sat Nov 19, 2005 12:18 pm

CENTER BBCODE
This is just a simple BBcode that will center the text for you. Nothing special, but can be quite useful. Very easy to install :)

SCREENSHOT
http://img512.imageshack.us/img512/1843/centered2li.gif

Also, a similar mod aligning the text to the right can be found here.

Code: Select all

##############################################################
## MOD Title: Center BBcode
## MOD Author: Amezis < N/A > (N/A) http://forum.global-rs.com
## MOD Description: Adds a [center] and [/center] BBCode tag for centering text when posting.
## MOD Version: 0.0.1
##
## Installation Level: Easy
## Installation Time: 1 Minute
## Files To Edit: 	includes/bbcode.php
#					templates/subSilver/posting_body.tpl										
## Included Files: n/a
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2 
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
############################################################## 
## Author Notes:
## 
## Only tested with phpBB 2.0.18, but should work on older versions too.
##
##############################################################
## MOD History:
##
##   2005-11-19 - Version 0.0.1
##      - MOD completed
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]------------------------------------------
#

includes/bbcode.php

#
#-----[ FIND ]------------------------------------------
#

	// [i] and [/i] for italicizing text.
	$text = str_replace("[i:$uid]", $bbcode_tpl['i_open'], $text);
	$text = str_replace("[/i:$uid]", $bbcode_tpl['i_close'], $text);

#
#-----[ AFTER, ADD ]------------------------------------------
#

	//
	// BEGIN Center BBCode MOD --------
	//
	$text = str_replace("[center:$uid]", '<div style="text-align: center;">', $text);
	$text = str_replace("[/center:$uid]", '</div>', $text);
	//
	// END CENTER BBCode MOD --------
	//

#
#-----[ FIND ]------------------------------------------
#

	// [i] and [/i] for italicizing text.
	$text = preg_replace("#\[i\](.*?)\[/i\]#si", "[i:$uid]\\1[/i:$uid]", $text);

#
#-----[ AFTER, ADD ]------------------------------------------
#

	//
	// BEGIN Center BBCode MOD --------
	//
	$text = preg_replace("#\[center\](.*?)\[/center\]#si", "[center:$uid]\\1[/center:$uid]", $text);
	//
	// END CENTER BBCode MOD --------
	//
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/posting_body.tpl

#
#-----[ FIND ]---------------------------------
#
# NOTE: the actual line to find is MUCH longer, containing all the bbcode tags
#
bbtags = new Array(

#
#-----[ IN-LINE FIND ]---------------------------------
#
'[url]','[/url]'

#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
,'[center]','[/center]'

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM 
Known bugs
None
Last edited by Amezis on Sun Nov 20, 2005 3:12 pm, edited 8 times in total.
Amezis

Wise men talk because they have something to say; fools, because they have to say something. -Plato

User avatar
okada1314
Registered User
Posts: 209
Joined: Sat Oct 29, 2005 10:51 am

Post by okada1314 » Sat Nov 19, 2005 12:30 pm

have demo?

Amezis
Registered User
Posts: 116
Joined: Sun Jul 24, 2005 9:10 am
Location: Oslo, Norway
Contact:

Post by Amezis » Sat Nov 19, 2005 12:33 pm

No, but you can look at the screenshot. It's just a simple BBCode mod ;)
Amezis

Wise men talk because they have something to say; fools, because they have to say something. -Plato

babydoll2u
Registered User
Posts: 214
Joined: Sun Sep 18, 2005 11:26 pm
Contact:

Post by babydoll2u » Sun Nov 20, 2005 4:33 am

I added it and it works GREAT! thank you :D


edited: I'm sorry, it was a center MOD from another author that I added and that works great. But yours seems to be missing the code to place a button with the other bb buttons :?
Last edited by babydoll2u on Tue Nov 22, 2005 6:29 am, edited 1 time in total.
Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience

Amezis
Registered User
Posts: 116
Joined: Sun Jul 24, 2005 9:10 am
Location: Oslo, Norway
Contact:

Post by Amezis » Sun Nov 20, 2005 10:03 am

Thank you! :D

I'll make another one which will put the text on the right, too.
Amezis

Wise men talk because they have something to say; fools, because they have to say something. -Plato

babydoll2u
Registered User
Posts: 214
Joined: Sun Sep 18, 2005 11:26 pm
Contact:

Post by babydoll2u » Tue Nov 22, 2005 6:14 am

-----------------------------
Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience

JSchwage
Registered User
Posts: 8
Joined: Sun Nov 27, 2005 1:00 am
Location: Rochester, NY
Contact:

Post by JSchwage » Tue Nov 29, 2005 8:42 pm

Works wonderfully! :D

A920
I've Been Banned!
Posts: 9
Joined: Thu Nov 17, 2005 5:53 am

Post by A920 » Wed Nov 30, 2005 8:48 pm

Your modification does not follow bbcode standardization guidelines.
http://www.phpbb.com/kb/article.php?article_id=147

User avatar
$unny
Registered User
Posts: 60
Joined: Sun Jan 08, 2006 8:42 am

Post by $unny » Sat Feb 11, 2006 5:47 am

:D great

it work

Thank U

BabyDreams
Registered User
Posts: 260
Joined: Wed Dec 07, 2005 9:28 pm

Post by BabyDreams » Thu Feb 16, 2006 10:11 am

Worked great for me too!

But is there a way to add a button for the code?

:D

Matt22
Registered User
Posts: 49
Joined: Mon Oct 25, 2004 11:28 am

Post by Matt22 » Thu Feb 23, 2006 11:36 am

Hi, this mod looks great but I'm looking for a sort of indentation, like one tab-space from the left. Is there anyway I could achive this?

Also how can I get bullet points?

Example (this is a Vbullitin board): http://totalbf2.com/forums/showthread.php?t=58391

happyjoy2
Registered User
Posts: 85
Joined: Fri Mar 10, 2006 4:27 pm

Post by happyjoy2 » Sun Mar 26, 2006 6:37 pm

I'm also wondering why I can't get the bbcode button to show on the posting screen next to the other bbcode tags. Any ideas?
2.0.22

RamEEz
Registered User
Posts: 321
Joined: Fri Jun 11, 2004 12:55 am

Post by RamEEz » Sun Jul 09, 2006 10:07 am

working perfectly fine

neten
Registered User
Posts: 1
Joined: Sat Feb 11, 2006 12:21 am

Post by neten » Sun Jul 23, 2006 8:14 pm

If you want a button... you have to do that:


Code: Select all

# 
#-----[ OPEN ]------------------------------------------ 
#
# languages/lang_english/lang_main.php
# 
#-----[ FIND ]------------------------------------------ 
#
$lang['bbcode_f_help'] = 'Font size: [size=x-small]small text[/size]';

# 
#-----[ ADD BELOW ]------------------------------------------ 
#
$lang['bbcode_y_help'] = 'Font Center: [center]text[/center] (alt+y)';



# 
#-----[ OPEN ]------------------------------------------ 
#
# templates/xxx/bbcode.tpl
# 
#-----[ FIND ]------------------------------------------ 
#
	<!-- BEGIN i_open --><span style="font-style: italic"><!-- END i_open -->
	<!-- BEGIN i_close --></span><!-- END i_close -->

# 
#-----[ ADD BELOW ]------------------------------------------ 
#
	<!-- BEGIN center_open --><div align="center"><!-- END center_open -->
	<!-- BEGIN center_close --></div><!-- END center_close -->



# 
#-----[ OPEN ]------------------------------------------ 
#
# templates/xxx/posting_body.tpl
# 
#-----[ FIND ]------------------------------------------ 
#
f_help = "{L_BBCODE_F_HELP}";

# 
#-----[ ADD BELOW ]------------------------------------------ 
#
y_help = "{L_BBCODE_Y_HELP}";


# 
#-----[ FIND ]------------------------------------------ 
#
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','
','
  • ','
','
  • ','
','[img]','[/img]','','');

#
#-----[ IN-LINE FIND ]------------------------------------------
#
'',''

#
#-----[ IN-LINE ADD ]------------------------------------------
#
,'[center]','[/center]'


#
#-----[ FIND ]------------------------------------------
#
<input type="button" class="button" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onClick="bbstyle(16)" onMouseOver="helpline('w')" />
</span></td>

#
#-----[ ADD BELOW ]------------------------------------------
#
# see "Note" at the beginning of this guide

<td><span class="genmed">
<input type="button" class="button" accesskey="y" name="addbbcode18" value=" Center " style="width: 60px" onClick="bbstyle(18)" onMouseOver="helpline('y')" />
</span></td>

#
#-----[ FIND ]------------------------------------------
#
<select name="addbbcode18" onChange="bbfontstyle('[color=' + this.form.addbbcode18.options[this.form.addbbcode18.selectedIndex].value + ']', '[/color]')" onMouseOver="helpline('s')">

#
#-----[ REPLACE WITH ]--------------------------------------------------
#
# see "Note" at the beginning of this guide

<select name="addbbcode20" onChange="bbfontstyle('[color=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/color]')" onMouseOver="helpline('s')">

#
#-----[ FIND ]------------------------------------------
#
</select> &nbsp;{L_FONT_SIZE}:<select name="addbbcode20" onChange="bbfontstyle('[size=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/size]')" onMouseOver="helpline('f')">

#
#-----[ REPLACE WITH ]--------------------------------------------------
#
# see "Note" at the beginning of this guide

</select> &nbsp;{L_FONT_SIZE}:<select name="addbbcode22" onChange="bbfontstyle('[size=' + this.form.addbbcode22.options[this.form.addbbcode22.selectedIndex].value + ']', '[/size]')" onMouseOver="helpline('f')">[/code]

EnJoY :wink: 8)

User avatar
sancarloscity
Registered User
Posts: 15
Joined: Tue Aug 08, 2006 1:18 pm
Contact:

Post by sancarloscity » Thu Aug 10, 2006 1:03 pm

tnx. it works.

but... do i hav to do this every time i install new template/s?

Post Reply

Return to “[2.0.x] MODs in Development”