antialiasis
04-10-2006, 10:00 PM
This hack in a nutshell: All users on your forum will be able to add optional BBCode to format all of their posts with.
This was inspired by DarthCow's user setable default BB code formatting for each post hack for vBulletin 3.0, borrows a couple of regular expressions from it and used it for reference in one spot. Everything else is my own.
This version of the Default BBCode hack does not have the "enable or disable default BBcode for individual posts you make" feature. The full hack is located here, but it is a Code Modification. Also go there for screenshots.
Version 1.02: Regular expression bug with colors and fonts fixed.
Version 1.01: Regular expression for "Default BBCode" field edited to support fonts with spaces in them.
ADDITIONAL FEATURES
-choose in your user CP whether to see any default BBCode at all
1 Product install
2 Custom profile fields
1 Template edit (in 2 templates)
2 Plugin edits
INSTALLATION INSTRUCTIONS
1. Download the product and import it.
2. Add two custom profile fields:
Profile field type: Single-line textbox
Title: Default BBCode
Description: You may choose to make a default BBCode formatting for each post. Allowed tags: [b] [i] [u] [left] [right] [center] [font] [color] [size] Please type in only the opening tags.
Max length of allowed user input: Doesn't really matter, but make sure it's enough
Display size: 25
Field Required: No
Field Editable by User: Yes
Private Field: Yes
Field Searchable on Members List: No
Show on Members List: No
Regular expression: ^(\[(b|i|u|left|right|center|font|color|size)(\=(\'|")?(#[0-9a-fA-F]+)?[\w\s]+)?('|")?\])*$
Display Page: Options: Other
(Here you can edit the description and regular expression to allow or disallow BBCode - in the regular expression, just make sure to separate all of them with |.)
Profile field type: Single-selection radio buttons
Title: Show Default BBCode?
Description: Selecting no will cause all posts to be displayed without users' automatic BBCode formatting.
Options: Yes
No
Set Default: Yes
Field Required: No
Field Editable by User: Yes
Private Field: Yes
Field Searchable on Members List: No
Show on Members List: No
Allow user to input their own value for this option: No
Display Page: Options: Thread Viewing
3. Make the following edits:
############## TEMPLATE EDITS ###################
In postbit and postbit_legacy
FIND
$post[message]
REPLACE with
<if condition="$post['dbbcopen'] AND ($bbuserinfo['field234'] == 'Yes')">$post[dbbcopen]</if>
$post[message]
<if condition="$post['dbbcclose'] AND ($bbuserinfo['field234'] == 'Yes')">$post[dbbcclose]</if>
Replace "field234" with your "Show Default BBCode?" field.
################## PLUGIN EDITS ##################
After installing the product, you will have to edit the following plugins:
Set default BBCode for post preview
Default BBCode setup
Find "field6" in both of them and replace it with your "Default BBCode" field.
At this point the installation should be complete. Enjoy!
This was inspired by DarthCow's user setable default BB code formatting for each post hack for vBulletin 3.0, borrows a couple of regular expressions from it and used it for reference in one spot. Everything else is my own.
This version of the Default BBCode hack does not have the "enable or disable default BBcode for individual posts you make" feature. The full hack is located here, but it is a Code Modification. Also go there for screenshots.
Version 1.02: Regular expression bug with colors and fonts fixed.
Version 1.01: Regular expression for "Default BBCode" field edited to support fonts with spaces in them.
ADDITIONAL FEATURES
-choose in your user CP whether to see any default BBCode at all
1 Product install
2 Custom profile fields
1 Template edit (in 2 templates)
2 Plugin edits
INSTALLATION INSTRUCTIONS
1. Download the product and import it.
2. Add two custom profile fields:
Profile field type: Single-line textbox
Title: Default BBCode
Description: You may choose to make a default BBCode formatting for each post. Allowed tags: [b] [i] [u] [left] [right] [center] [font] [color] [size] Please type in only the opening tags.
Max length of allowed user input: Doesn't really matter, but make sure it's enough
Display size: 25
Field Required: No
Field Editable by User: Yes
Private Field: Yes
Field Searchable on Members List: No
Show on Members List: No
Regular expression: ^(\[(b|i|u|left|right|center|font|color|size)(\=(\'|")?(#[0-9a-fA-F]+)?[\w\s]+)?('|")?\])*$
Display Page: Options: Other
(Here you can edit the description and regular expression to allow or disallow BBCode - in the regular expression, just make sure to separate all of them with |.)
Profile field type: Single-selection radio buttons
Title: Show Default BBCode?
Description: Selecting no will cause all posts to be displayed without users' automatic BBCode formatting.
Options: Yes
No
Set Default: Yes
Field Required: No
Field Editable by User: Yes
Private Field: Yes
Field Searchable on Members List: No
Show on Members List: No
Allow user to input their own value for this option: No
Display Page: Options: Thread Viewing
3. Make the following edits:
############## TEMPLATE EDITS ###################
In postbit and postbit_legacy
FIND
$post[message]
REPLACE with
<if condition="$post['dbbcopen'] AND ($bbuserinfo['field234'] == 'Yes')">$post[dbbcopen]</if>
$post[message]
<if condition="$post['dbbcclose'] AND ($bbuserinfo['field234'] == 'Yes')">$post[dbbcclose]</if>
Replace "field234" with your "Show Default BBCode?" field.
################## PLUGIN EDITS ##################
After installing the product, you will have to edit the following plugins:
Set default BBCode for post preview
Default BBCode setup
Find "field6" in both of them and replace it with your "Default BBCode" field.
At this point the installation should be complete. Enjoy!