PDA

View Full Version : User Default Font/Color/Size hack


TalkHardRandy
26 Feb 2003, 20:42
First hack... please be gentle :confused: :

WHAT IT DOES:

It allows the user to specify in their profile what size, color and font that they wish to use in all their posts. This is esentially the same as surrounding stuff with SIZE, COLOR, FONT, but makes it easier.

It also uses the vbcode templates already in the system, so users can select from any of the fonts & colors you have already defined. This avoids users inputing colors that don't exist and fonts that no one else has on their systems.

INSTALLABLES

3 file mods
4 template adds
3 template mods

PROPS

Palmer ofShinra inspired the original version here (http://www.vbulletin.org/forum/showthread.php?threadid=32104), so massive props to him. I wanted to take his idea and make it more user friendly (and was tired of trying to explain to people why 'puke green' didn't work as a color).

Also, every other hacker out here (Lesane, Erwin, FireFly, Xenon, C.Birch, futureal, and a hundred others) for busting their butts and putting hacks out and for saying that if you want to do something, learn to do it. Inspiration at its finest.

BUGS

If you run TomBot, TomBot has a problem with the FONT/COLOR/SIZE tags. The fix is two posts below

Okay... let me know

FIXES

1) Fixed Spelling of 'Verdana' - Thanks Vivi!
2) Fixed for Multiple Styles - Thanks Zelda!
3) Added & fixed user ability to use default via ON/OFF - Again, Thanks Zelda!
4) Added ability to remember defaults.

TalkHardRandy
26 Feb 2003, 20:44
What it looks like in the User CP...

TalkHardRandy
26 Feb 2003, 20:50
Okay, if you're like me your running TomBot & you've figured out that he/she doesn't like the color, font, size tags... especially if you're teaching to it.

In both newreply.php & newthread.php, find this section:


// ##################### BEGIN FONT COLOR SIZE HACK ##################
if ($bbuserinfo[default_fcs]="0") {
$message = "."]."]."]".$message."";
}
// ##################### END FONT COLOR SIZE HACK ####################



Replace it with:


// ##################### BEGIN FONT COLOR SIZE HACK ##################
if ($foruminfo['forumid']!=="FORUM#" || $bbuserinfo[default_fcs]="0") {
$message = "."]."]."]".$message."";
}
// ##################### END FONT COLOR SIZE HACK ####################


Where FORUM# is the forum where your TomBot is running. If you have multiples, and a ||. To figure out what forum you TomBot is running in, check the tomstalkerbot.php for the $ttb_forumid variable.

NOTE: If it doesn't look like this in your files, you need to go back to post #1 and reinstall the hack.

Vivi Ornitier
26 Feb 2003, 22:23
hey great job! been waitin for somethin like this but the queries don't wokr.

I thin it's too many ' and also u spelt Veranda instead of Verdana in the queries

TalkHardRandy
26 Feb 2003, 22:30
Okay... spelling bugs are fixed (which is why Notepad should have a spell checker :nods: )

As for the query, I don't know why it wouldn't work... I copied and pasted it out of MySQL and tried it again... :confused:

This is what my results look like... what about yours?

Disturbed
27 Feb 2003, 00:40
i will test this locally and report you the results :)

One-Team
27 Feb 2003, 02:51
Great Hack
I will Install it :banana: :banana:

Zelda-King
27 Feb 2003, 11:03
I'm trying this out on vB 2.2.9.

Good hack. One snag though. There are 16 of each option beside each other. Also the number of times the options are indicated goes up by 1 as you go along. So in the first size one it says 'small medium large' then in the next one it says 'small medium large small medium large' and so on. (I got rid of the LARGER font sizes. I don't like seeing posts in like size 5+ font or something personally. :D)

Here, I took a screenshot of the bug (see attachment).

It's something to do with the member.php because if I revert that file the templates work fine.

EDIT: I fixed it. Basically, instead of using eval("\$getfontcolor.= \"".gettemplate("vbcode_colorbits")."\";");
eval("\$getfontsize.= \"".gettemplate("vbcode_sizebits_mod")."\";");
eval("\$getfontfonts.= \"".gettemplate("vbcode_fontbits")."\";");

eval("\$postfontcolor.= \"".gettemplate("post_font_color")."\";");
eval("\$postfontsize.= \"".gettemplate("post_font_size")."\";");
eval("\$postfontfonts.= \"".gettemplate("post_font_fonts")."\";"); use eval("\$getfontcolor = \"".gettemplate("vbcode_colorbits")."\";");
eval("\$getfontsize = \"".gettemplate("vbcode_sizebits_mod")."\";");
eval("\$getfontfonts = \"".gettemplate("vbcode_fontbits")."\";");

eval("\$postfontcolor = \"".gettemplate("post_font_color")."\";");
eval("\$postfontsize = \"".gettemplate("post_font_size")."\";");
eval("\$postfontfonts = \"".gettemplate("post_font_fonts")."\";");.

You just shouldn't have the '.'s before the '='s.

The trouble is this can pose problems for boards that have several styles. If the top 'default' option was truly 'default' and didn't insert any vB code that would be perfect.

I was thinking something along the lines of // ##################### BEGIN FONT COLOR SIZE HACK ##################
if($bbuserinfo[post_color] == "Default"){
$message = "."]."]".$message."";
} else {
$message = "."]."]."]".$message."";
// ##################### END FONT COLOR SIZE HACK #################### but that is parsed wrong in the top line. Needs correcting. That code just gets me an unexpected T_DEFAULT.

TalkHardRandy
27 Feb 2003, 16:25
Okay... fixed the file with your first fix Zelda... danke.

As to the second part, I'm going to put an on/off button in there so people can select which features they wish to use. It'll double the options in the CP and make the newreply & newthread parts bigger, but you're right it is kinda a pain...

Dean C
27 Feb 2003, 16:31
Nice hack Randy. I saw this and thought you would have had a numeric field to enter for the font size. It's in dropdowns which i would have suggested anyway. Excellent hack pal :)

- miSt

Zelda-King
27 Feb 2003, 16:34
I'm going to put an on/off button in there so people can select which features they wish to use.As long as the default for the ON/OFF button is 'OFF' so people's posts don't override various theme colour defaults unless they actually update their profile to do so, then that'd suit me fine.

Actually my default theme text colour IS black so it's not much problem for me personally.

TalkHardRandy
27 Feb 2003, 16:58
Danke Mist...

For the sake of sanity, it's an either or deal... you can use the defaults or you can specify your own... default will be set to 'ON', so all it does is post the $message w/o the extras.

TalkHardRandy
27 Feb 2003, 17:57
Okay... I've updated the hack.

It now give an option to use the forum defaults via an ON/OFF. If you have multiple styles, this should clean it up. But, I don't run multiple styles, so I can't be 100% sure. Plus, I think I'm figuring out how to keep the default values from reseting...

Zelda-King
27 Feb 2003, 18:31
I'm getting this database error when I update my profile:

Database error in vBulletin 2.2.9:

Invalid SQL: UPDATE user SET birthday='0',signature='(Sig)',customtitle='1',usertitle='(Rank)',email='(email) ',parentemail='',coppauser='0',homepage='homepage',icq='',aim='',yahoo='',usergr oupid='6',default_fcs='1',post_size='2',post_font='times new roman',post_color='black' WHERE userid='1'
mysql error: Unknown column 'default_fcs' in 'field list'

mysql error number: 1054

Date: Thursday 27th of February 2003 12:20:27 PM
Script: http://www.gamercrossfire.net/bb/bb/member.php
Referer:

Seems to be requesting the wrong URL. :/

Anyway, at least my posts were default colour before I updated it this time. :)

TalkHardRandy
27 Feb 2003, 18:36
The SQL query didn't take. It's because you already have three of the four fields in there. Run this query instead:

ALTER TABLE `user` ADD `default_fcs` INT( 1 ) DEFAULT '1' NOT NULL AFTER `inforum';

Zelda-King
27 Feb 2003, 18:54
OK, I fixed that.

Now everything stays on default regardless. Either I'm doing something wrong or your PHP code needs an } else { for the default_fcs in newreply.php/newthread.php

TalkHardRandy
27 Feb 2003, 19:21
Okay, you have to go into your profile, turn off the defaults, then select what you want it to change. Save your profile, then try it.

For some reason that I'm still working out, the user selections don't come back as the default values. I'm working on it, however.

Zelda-King
27 Feb 2003, 19:26
Yeah, whether I turn off the defaults or not now the posts come out default, though before you put the 'default' check in it worked fine.

Then again, if I edit the PHP to if ($bbuserinfo[default_fcs]="1") {
$message = "."]."]."]".$message."";
} then I get the reverse situation.

I tried putting if ($bbuserinfo[default_fcs]="0") {
$message = "."]."]."]".$message."";
} else {
$message = "$message";
} in newthread/newreply.php but that didn't help.

Boofo
27 Feb 2003, 20:44
Would there be a way to have a testing box so you could compare the board defaults with whatever you picked to see how they look compared to one another? That way you wouldn't have to go all the way to make a post to see how it would look.

TalkHardRandy
27 Feb 2003, 21:27
He's right... it doesn't matter if its on or off, it uses whatever you have selected....

EDIT:

Okay, in the newreply & newthread:

change:


if ($bbuserinfo['default_fcs']="0") {
$message = "."]."]."]".$message."";
}


to


$usingdefaults="$bbuserinfo[default_fcs]";
if ($usingdefaults=="0") {
$message = "."]."]."]".$message."";
}


For some reason, it doesn't like using $bbuserinfo without a variable.

Text file updated... if that gets everyone working, I've got the fix to the defaults.

Zelda-King
27 Feb 2003, 21:59
I tested it. Works fine. Great work!

What'd be even better is if people could have custom fonts set but still use the default colours. Size/font isn't an issue but you really should be able to use two out of the three functions and still be able to keep to the default colour (unless you set it manually otherwise), for the sake of multiple forum styles.

Other than that, there's the matter of having to fix your settings every time you edit your profile.

Once that's all sorted out I'd say you're good to go. Also, the ON/OFF button stays as you set it (it doesn't revert) so that's good. :)

TalkHardRandy
27 Feb 2003, 22:38
DEFAULTS IS FIXED!!!

It's sloppy & I don't like it, but short of rewriting every template and dumping a bunch of extras into the member.php, it should work. Text file has been updated. Be sure to read through it as I change all the templates.

Let's see what breaks now, shall we?

TalkHardRandy
27 Feb 2003, 22:56
Originally posted by Zelda-King
What'd be even better is if people could have custom fonts set but still use the default colours. Size/font isn't an issue but you really should be able to use two out of the three functions and still be able to keep to the default colour (unless you set it manually otherwise), for the sake of multiple forum styles.

You mean their own fonts that they use? It could be done, but it wouldn't be displayed for the others unless they had the same fonts installed.

I included font size because, I love Garamond, but set to 2 is too small... it needs to be set to 3. Other fonts are the same way.

Glad you guys like... definately good for the ol' ego...

Zelda-King
27 Feb 2003, 23:05
Yeah, I just mean people might want to use custom fonts in the default colours (which'd cause less of a clashing problem with themes unless they wanted to alter their colour). Like... I could select your 'times new roman' custom font, update the profile and the colour would be default so it goes with all the themes.

I installed the updates. I see why you don't like it. It's just a teensy bit odd when you change your customs and you see your old choice repeated at the top, but yeah, it works. You made pretty good progress today.

Link14716
27 Feb 2003, 23:53
This is actually a lot easier to do with custom profile fields and doing it that way gives your users the freedom to enter a HEX value, so that's how I'd do it. ;)

TalkHardRandy
28 Feb 2003, 00:12
Originally posted by Link14716
This is actually a lot easier to do with custom profile fields and doing it that way gives your users the freedom to enter a HEX value, so that's how I'd do it. ;)

Agreed... it was easier that way.

The problem we kept coming across was the users would send PM's saying, "Why doesn't my color/font work?", only to find out that 'seafoam' isn't a real color (and don't ask about the HEX code problems) or someone would have 'Burton's Nightmare' loaded on their computer, but no one else did.

We wanted to make it easier on the users who use it.

TalkHardRandy
28 Feb 2003, 00:22
Originally posted by Zelda-King
Like... I could select your 'times new roman' custom font, update the profile and the colour would be default so it goes with all the themes.

I see what you mean... an ON/OFF per option.

I tried it originally and discovered it makes a whole bunch of extra code in the newthread & newreply. Each would have a SELECT statement with six options, as opposed to a single on/off. If you only want to user one part of it, Palmer's hack is much simplier, except, like I said, you have to input manually what you want. I never figured out a way to tie it into the vbcode_bits.


You made pretty good progress today.

Thanks a lot Z... you help muchos. I'm just waiting to see if anyone else installs and has problems/suggestions. One of my users suggested adding a glow option to it, but I told him to use the GLOW tags instead. Hurts my eyes :laugh:

nnjj.net
28 Feb 2003, 12:41
exe. is't ok to install it or still having probs?

thanx

Zelda-King
28 Feb 2003, 15:46
It's working fine for me. I added a load of fonts in the vbcode_fontbits template. All tested on vB first to make sure they work for everyone. I've got 30 fonts in there now. :)

And here it is;
<option value="verdana">Verdana</option>
<option value="arial">Arial</option>
<option value="times new roman">Times new roman</option>
<option value="courier new">Courier</option>
<option value="chasm">Chasm</option>
<option value="dolphin">Dolphin</option>
<option value="kelt">Kelt</option>
<option value="ms sans serif">Ms sans serif</option>
<option value="mirror">Mirror</option>
<option value="quixley let">Quixley let</option>
<option value="ruach let">Ruach let</option>
<option value="shorthand">Shorthand</option>
<option value="surfer">Surfer</option>
<option value="tahoma">Tahoma</option>
<option value="terminal">Terminal</option>
<option value="westminster">Westminster</option>
<option value="bangle">Bangle</option>
<option value="eurasia">Eurasia</option>
<option value="lynda cursive">Lynda cursive</option>
<option value="gaze">Gaze</option>
<option value="lucida sans">Lucida sans</option>
<option value="paris">Paris</option>
<option value="system">System</option>
<option value="tempus sans">Tempus sans</option>
<option value="university roman let">University roman let</option>
<option value="victorian let">Victorian let</option>
<option value="bimini">Bimini</option>
<option value="fixedsys">Fixedsys</option>
<option value="la bamba let">La bamba let</option>
<option value="cataneo bt">Cataneo bt</option>
I'd put them alphabetically but the default 'first' one is Verdana. :D

I recommend that setup. Those fonts're OK on vB as opposed to... some other ones.

TalkHardRandy
28 Feb 2003, 17:27
Originally posted by nnjj.net
exe. is't ok to install it or still having probs?

thanx

No problems... all fixed...

Boofo
28 Feb 2003, 19:01
Zelda-King, those fonts will only work for the user if they themselves also have them installed on their machine (version of Windows). The fonts from Windows XP won't all work on Windows 95 or Windows 98 as they don't have all of the same fonts as Windows XP does.

Zelda-King
28 Feb 2003, 19:33
Yeah, these're pretty 'unspecial' fonts so I'm banking on there being no problems. I'll see how it goes. Having said that, mine doesn't even have Book Antigua! O_O

Boofo
28 Feb 2003, 20:12
I have a whole crapload too, but if they don't have a font they picked, it should just default to Arial, so you should be ok. ;)

Zelda-King
28 Feb 2003, 21:35
Yeah, my 'Book Antigua' comes out as arial. I should get a good test run in this sunday from more people so I'll update if there're problems.

EDIT: There's a bug somewhere. I'm seeing a few people with quite big fonts. The vB code being [color=][font=][size=]Text[/size][/font][/color]

TalkHardRandy
03 Mar 2003, 21:08
Zelda, make sure that in the database the 'default_fcs' is set to '1' as a default. I had a couple of new users that happened to also. Plus, the text file is fixed.

Zelda-King
03 Mar 2003, 23:54
My default is 1. I'll see what I can do with this updated text file.

TalkHardRandy
05 Mar 2003, 15:51
Hmmm... what are their settings in the database?

Vivi Ornitier
06 Mar 2003, 03:15
the DB queries still don't work!! ahhh!!!





ADD `post_size` VARCHAR( 1 ) DEFAULT '2' NOT NULL

MySQL said:


You have an error in your SQL syntax near 'ADD `post_size` VARCHAR( 1 ) DEFAULT '2' NOT NULL' at line 1





I get that error from phpadmin

zootsuit
06 Mar 2003, 05:44
You have to run this as one query:

ALTER TABLE `user` ADD `post_font` VARCHAR( 25 ) DEFAULT 'Verdana' NOT NULL ,
ADD `post_color` VARCHAR( 25 ) DEFAULT 'black' NOT NULL ,
ADD `post_size` VARCHAR( 1 ) DEFAULT '2' NOT NULL ;

msimplay
06 Mar 2003, 12:20
does this hack work for vbulletin 2.3 release candidate one ?

zootsuit
06 Mar 2003, 13:00
I have no clue. We are still running 2.2.5.

TalkHardRandy
06 Mar 2003, 17:21
Should, unless they changed the way that messages are inserted into the DB. Just backup your DB & the three PHP files. And let us know if it works...

geniuscrew
06 Mar 2003, 22:50
Is there any way to use this hack with stylesheets?

nnjj.net
07 Mar 2003, 14:16
so still not working well !

geniuscrew
07 Mar 2003, 14:29
Working fine on 2.2.9 - need the style sheet option because the font size in pixels are better

Zelda-King
07 Mar 2003, 17:30
Originally posted by TalkHardRandy
Hmmm... what are their settings in the database? Well, I dropped the tables and readded them from the updated textfile and so far I've had no further problems. As for the settings I had in the first place I copied and pasted them into the query window from the textfile. Weird, but I've managed nearly a week now with things being OK and I've had no complaints about people not seeing the custom fonts yet either (the ones I added).

TalkHardRandy
07 Mar 2003, 19:44
Originally posted by geniuscrew
need the style sheet option because the font size in pixels are better

Definately... I'll try to figure out CSS & how to pull the defaults from that into the hack...

I'm also going to put an option to disable the colors & fonts on certain posts (i.e. newthread & newreply templates). Sometimes, you don't want to post in a colour, but only in that thread.

geniuscrew
07 Mar 2003, 22:28
Originally posted by TalkHardRandy


I'll try to figure out CSS & how to pull the defaults from that into the hack...



I'll look forward to seeing that.

Cheers :)

Zelda-King
08 Mar 2003, 10:25
Right, I've still got some guy with that weird huge font, and I have the database tables exactly as they're meant to be in the hack. It looks like the others fixed it by updating their profiles.

msimplay
15 Mar 2003, 06:12
it works on 2.3
but theres a potential problem
what if u want to change ur font color in the post ie
not use the that u chose in user cp

for example if u picked ms sans serif and color green

but just for one post u want to change it or even for just one line
can u do that ?

zootsuit
15 Mar 2003, 07:46
Yesterday at 11:12 PM msimplay said this in Post #50 (http://www.vbulletin.org/forum/showthread.php?postid=366533#post366533)
it works on 2.3
but theres a potential problem
what if u want to change ur font color in the post ie
not use the that u chose in user cp

for example if u picked ms sans serif and color green

but just for one post u want to change it or even for just one line
can u do that ?

Yep. Just choose your font and/or color from the reply page as you would normally. :)

LangTuDaTinh
17 Mar 2003, 17:48
one little idea, add an option in newthread, editpost, newreply and edit option from usercp, where use can turn on or off this hack by checkbox or radio button.

geniuscrew
24 Mar 2003, 15:36
This is all getting very confusing

If you want to only use it for some posts, then you don't need the hack since you can do that anyway.

Also I figured the CSS out - with a little help from amykhar.

So, for anyone who prefers CSS sizes to HTML sizes

replace


$message = "."]."]."]".$message."";


with


$message = "<font style=\"color:".$bbuserinfo[post_color]."; font-family:".$bbuserinfo[post_font]."; font-size: ".$bbuserinfo[post_size]." px;\">".$message."</font>";


You will also need to change the length of default_pcs and post_fontsize [Note: has to be in pixels or whatever CSS format you're using]

WEForums
23 Apr 2003, 00:02
Nice hack and all but am I the only one who experiences a 'bug' when making quotes? It's like this:

Origina
lly posted by USERNAME

I know it's trivial but I just want to know if others have the same problem. I am sure it's easily fixable though.

geniuscrew
23 Apr 2003, 01:11
Nope - I have this problem too :/

subu1
23 Apr 2003, 06:03
it works fine on 2.2.8, quotes too.

thank you;)

subu1
23 Apr 2003, 10:12
hi my verdana is green, i want to have that in black. Black is verdana or not???


greetz subu1

LangTuDaTinh
23 Apr 2003, 10:30
Yesterday at 04:02 PM WEForums said this in Post #54 (http://www.vbulletin.org/forum/showthread.php?postid=385735#post385735)
Nice hack and all but am I the only one who experiences a 'bug' when making quotes? It's like this:



I know it's trivial but I just want to know if others have the same problem. I am sure it's easily fixable though.


i have the same problem...i don't know because of this hack or not...

but i think it's depend on which font that i selected. because some of my users have no problem when they quote...but strangly...i got the same problem.

gwhooooey
26 Apr 2003, 01:51
This assumes three things: 1) Your default font is 'Veranda'; 2) your default color is 'black'; and 3) Your default size is '2'. If these are different, please change to reflect.

I'm using 2 styles, on one the default colour is black, on the other it's kinda silver....

So um...What do I do?

gwhooooey
27 Apr 2003, 02:49
Can anyone help?

mcyates
21 Jun 2003, 18:46
its not working on mine, 2.30 BUGGER

Roxie
27 Oct 2003, 19:55
I can seem to get the txt file to download. :/

Roxie
27 Oct 2003, 20:12
ahhh. found a way to do it.

Roxie
27 Oct 2003, 21:01
Nice hack and all but am I the only one who experiences a 'bug' when making quotes? It's like this:



I know it's trivial but I just want to know if others have the same problem. I am sure it's easily fixable though.
anyone figure out how to fix this?

Assault
04 Feb 2004, 00:51
dis work for 2.3.x?

ashley53680
24 Feb 2004, 00:49
Anyone have this for VB 3.0.0 yet??

I tried to find the part to edit in member.php and it wasn't there... :eek:

FWF
13 Apr 2004, 00:34
id love to see this for vB 3 someone has to make it

saree
03 Apr 2005, 13:29
yes i agree with you FWF i wish i can see it in vb3