PDA

View Full Version : Display custom titles AND standard titles in posts


JJR512
02-10-2002, 10:00 PM
This is a small hack that I wrote several months ago. Originally it was only a template mod, then turned into a hack but remained in the template mods forum at vbulletin.com, so it never made it over here.

Basically, all it does is show both a custom title, selected by the user, and the user's standard title (Junior Member, Member, Moderator, etc.) in posts. It uses a custom profile field that you create through the admin cp to store the custom title.

As I said, it's an older hack by me, and was originally tested on 2.0.3. It still works for me on 2.2.2, though.

KuraFire
02-11-2002, 10:29 AM
Thanks, but, uhm... does this hack of yours mean that the users will enter their CUSTOM title in a User Profile Field? If so, then it's no good for me, see the link in my signature. :(

JJR512
02-12-2002, 01:52 AM
I saw the link in your signature, and I really cannot understand at all what it is, exactly, you want. All my hack does is put a new profile field in a user's control panel for them to enter any custom title that they might want for themselves. The difference between this and the built-in Custom Title feature is that in a post, you will see not only the custom title, but the standard title, too.

It is just another custom user profile field. It's exactly what you wuold use if you wanted a field for, say, "My Pet's Name" or "Where I was Born" or "My Favorite Color." The ONLY reason why this is a hack is because I added custom code to functions.php that checks to see whether or not there is any value in this field, so that if there is NOT, then not even a blank line would show up where the custom title is supposed to go.

Now I see you talking about the glow effect...if you want the custom title to glow, all you have to do is add the appropriate HTML to the part you add to functions.php.

I'm sorry if this isn't exactly what you wanted, but I didn't make this hack for you, specifically...as I said, this is an older hack by me, released September 2001, originally as a template modification, which is why up until now, it was still left in the template mods forum at vbulletin.com. Since it had changed into a hack at the time, and nobody ever moved it to the hacks forum (despite me asking for that), it never got moved over here. The fact that you asked for something that I thought at least was similar to what I had already done prompted me to find this so I could point you to it, and failing to find it here, I realized it never came over here, hence the re-release at this time.

Recluse
02-12-2002, 06:11 AM
done it, work sweet. thanks

KuraFire
02-12-2002, 10:09 AM
JJR, thanks, I appreciate. But my problem is that users want their own particular glow (i.e. user A wants a blue glow, user B a red, etc. etc.) and if I do this through a User Profile Field, the html code for a glow-tag will appear in their profile field line, However, the HTML code contains a " and that will screw up the layout of the page since it makes the system believe that it is the end of the Input Type Field's starting value, which it isn't of course. Now, if I were to have it work like the Custom Titles itself, the Current setting that a user has will not be displayed as a value in the profile field, but rather next to it (or above it), so that the field itself remains empty and won't have that " in it to mess up the table structure. That's why I need this to be outside of the User Profile Fields. (or find a method that will alter the submission of your Edit Profile page in the UserCP, so that it will UPDATE only when a user puts something in the field, and when not it won't remove it but instead, leave it alone).

JJR512
02-12-2002, 05:23 PM
How about adding a second custom profile field, one where the user can enter the glow color he/she wants?

Currently, the code you add to functions.php is this:
if ($post[field5]) {
$extratitle="$post[field5]<br>";
} else {
$extratitle="";
}

If you added a second field for the glow color, you could change the addition to something like this, assuming the new field's name was field6:
if ($post[field5]) {
if ($post[field6]) {
$extratitle="<div style=\"width:100%; filter:glow(color=$post[field6], strength=3)\">$post[field5]</div>";
} else {
$extratitle="$post[field5]<br>";
}
} else {
$extratitle="";
}
This also checks to see whether or not there is a glow color specified, so that it won't try to make something glow if there's not color. Heck, if you wanted to, you could even make another custom profile field for the strength, which would be field7, and just replace strength=3 with strength=$post[field7]!

Hope that helps.

KuraFire
02-12-2002, 05:50 PM
Wow, Thanks, I think I can fix everything all at once with this, that was great! I'll implement it on my testboard and see how it goes, if it doesn't work I'll let ya know, and if it does I'll be back worshipping your 1337ness! ;)

Thanks! :D

KuraFire
02-12-2002, 06:54 PM
IT WORKS!!!

Thanks - I'm gonna install it on my online board now! Many thanks, this solves so much problems now! :up:

https://vborg.vbsupport.ru/external/2002/02/2.gif

Jakeman
02-12-2002, 09:30 PM
i do this without file mods. just put $post[fieldx] in your postbit where x is the id # for the custom profile field for your custom title. custom profile fields can be made from the admin cp. no file mods needed.

KuraFire
02-12-2002, 10:23 PM
Jakeman, you should've read the thread before you posted. Normal user profile additions won't work with glows, that's the whole point here.

JJR512
02-13-2002, 03:59 AM
Jakeman, in this hack, you DO add the custom profile field through the admin cp.

What the file modification does it prevents a blank line from showing up on the thread page if a user has not put in a custom title. It's just a simple little routine that checks for a value in $post[fieldX], and if there is one, it assigns the value of $post[fieldX] to $extratitle, and $extratitle is formatted to include a line break. If there is no value in $post[fieldX], a blank string is assigned to $extratitle. When you put $extratitle in the postbit template, you do NOT put a linebreak between it and the next line (which is the standard title); that way, if it's blank, there will be no empty line, but if it's not blank, the variable includes a line break to keep the flow right.

In other words, it's done strictly for appearance.

As I said, originally, this was just a template modification that I pointed out at vbulletin.com. Someone asked me how to surpress the blank line that would show up for users with no custom title, and that's how it evolved into a file modification hack.

:)

Jakeman
02-13-2002, 04:01 AM
glowing isn't compatible accross all browsers and platforms so nya! :p

and glowing does work with custom fields, i just tested it.

meh, if it was me i would put a statement in my phpinclude instead of editing php files, but that's me, either way works for the spacing thingy. i hate editing php files, i will take templates over file mods any day, even if it adds more overhead to every page :D

JJR512
02-13-2002, 04:08 AM
It's my understanding that if a browser does not support glowing, the plain text will still be seen. And as I just said, the main point of it being a hack is not to support glowing; that's just a neat side-effect that was possible, and I showed how to do it. As I just said, the MAIN purpose to this being a hack is so that a blank line does not show up in between the user name and standard title if there is no custom title.

What I mean is this. If this was NOT a hack, a user with no custom title would look like this in the author info area of a message:
User1

Registered

While a user WITH a custom title would look like this:
User2
Super-Cool Dude
Registered

It's the blank line for User1 in below his name and above his title ("Registered") that someone asked me to make not show up. That's why I had to turn it into a hack, so that now, User1 looks like this:
User1
Registered

While User2 continues to look exactly the same.

JJR512
02-13-2002, 04:09 AM
What kind of statement would you put in your phpinclude template? :confused:

Jakeman
02-13-2002, 05:23 AM
sorry, i'm being a bit of a troll. :(

erm, you can put php code in your phpinclude template. you should be able to set up the condition in there, right?

KuraFire
02-13-2002, 07:52 AM
Originally posted by Jakeman
and glowing does work with custom fields, i just tested it.

I'd like to know how your Edit Profile page looks like if you've got an HTML glow in it. With me, it f*cked up the layout of the page... :( (due to the "-sign in glow codes)

JJR512
02-13-2002, 06:24 PM
Originally posted by Jakeman
sorry, i'm being a bit of a troll. :(

erm, you can put php code in your phpinclude template. you should be able to set up the condition in there, right?
Yeah, but there's a reason why vBulletin is made up of a bunch of separate files, rather than all the code being in the phpinclude template.

Jakeman
02-13-2002, 10:51 PM
Originally posted by JJR512

Yeah, but there's a reason why vBulletin is made up of a bunch of separate files, rather than all the code being in the phpinclude template.

Originally posted by Jakeman
i will take templates over file mods any day, even if it adds more overhead to every page :D

:D

JJR512
02-14-2002, 01:25 AM
Of course I remember typing my quote, and I already read your quote...so what's the point? Nothing new to add?

Jakeman
02-14-2002, 03:40 AM
Originally posted by JJR512
Of course I remember typing my quote, and I already read your quote...so what's the point? Nothing new to add?

ugh, nOOb. http://130.94.172.202/forum/images/smilies/wtf.gif

KuraFire
02-14-2002, 11:20 AM
ugh, weird people...

;)

Jakeman
02-14-2002, 04:08 PM
Originally posted by KuraFire
ugh, weird people...

;)

you called?~ ;)

KuraFire
02-15-2002, 04:53 PM
Yeah, now answer my question. How does your Edit Profile page look like if you've got an HTML glow in it that includes "-signs, successfully screwing up the layout is what it does in Explorer. :)

Freddie Bingham
02-15-2002, 08:56 PM
Hint: In vb3 you won't need to add any hacks to decide if that <br /> should appear or not based on the value of a field...Can't say any more than that :)

KuraFire
02-15-2002, 09:31 PM
freddie, I've got a tip for vB 3: I don't know exactly what you guys did to make quotes NOT mess up the `input type=text` fields in the Admin Panel when editing a user's stats, but I really would like to see that in a normal user's Edit Profile page as well. :):up:

And my god, make :up: (:up:) a default `smilie` in vB 3, every forum that I go to I make a suggestion to the admins to change that into the thumbs-up icon (and :down: for the thumbs-down) and everywhere they go "hey, good one, I'll do that right away!" - much easier to have it be part of the default set, wouldn't you say? :)

Freddie Bingham
02-15-2002, 09:34 PM
What do you mean, quotes mess up? Are you saying there is a bug?

Anyway just htmlspecialchars() the value before you give it to the input field and " becomes &quot;

KuraFire
02-15-2002, 10:09 PM
Yes, well, if a user would have a glowing custom title (as is very common on INA and on my board) in a user profile field (instead of as a real custom title, because we're not touching titles themselves on the Couch) it would mess up the Edit Profile page layout because a glow contains " in it, and on the Edit Profile page the user's input is placed as a value inside the text-input-field but it isn't yet htmlspecialchars()'d, so those "s in a glow would make a mess of it.

Jakeman
02-16-2002, 01:36 AM
Originally posted by freddie
Hint: In vb3 you won't need to add any hacks to decide if that <br /> should appear or not based on the value of a field...Can't say any more than that :)

POWER FIELDS! ;)

Freddie Bingham
02-16-2002, 06:00 PM
When you put a " in a custom profile field, it is converted to &quot; when the user submits the page. So upon editing the value of &quot; is what is loaded so it doesn't break the field. I still fail to see where any bugs are.

Jakeman : it has nothing to do with the fields, as we said before it is much more powerful than that.

KuraFire
02-16-2002, 10:03 PM
try putting a table glow in a user's profile field, and then looking at their Edit Profile page. Layout = borked.

Freddie Bingham
02-16-2002, 10:25 PM
Give me the text you would input to do that.

KuraFire
02-16-2002, 10:56 PM
<table style="filter:glow(color=white)"><font color=red>&nbsp;She Devil&nbsp;</font></table>

KuraFire
02-16-2002, 11:03 PM
oh, btw, it's the same if you _do_ add the TR and TD tags.

Jakeman
02-16-2002, 11:10 PM
Originally posted by freddie
Jakeman : it has nothing to do with the fields, as we said before it is much more powerful than that.

more powerful than fields... POWER FIELDS! ;)

sigh... *me dies*

Freddie Bingham
02-16-2002, 11:55 PM
Originally posted by KuraFire
<table style="filter:glow(color=white)"><font color=red>&nbsp;She Devil&nbsp;</font></table> I still fail to see the problem as when that is saved it is sent through htmlspecialchars(), which btw makes it useless for you as it will not display as HTML when it is called in the postbit template. When edited, the underlying html appears as:

<input type="text" class="bginput" name="field1" value="&lt;table style=&quot;filter:glow(color=white)&quot;&gt;&lt;font color=red&gt; She Devil &lt;/font&gt;&lt;/table&gt;" size="25" maxlength="250">

KuraFire
02-17-2002, 09:53 AM
Originally posted by freddie
I still fail to see the problem as when that is saved it is sent through htmlspecialchars(), which btw makes it useless for you as it will not display as HTML when it is called in the postbit template. When edited, the underlying html appears as:

<input type="text" class="bginput" name="field1" value="&lt;table style=&quot;filter:glow(color=white)&quot;&gt;&lt;font color=red&gt; She Devil &lt;/font&gt;&lt;/table&gt;" size="25" maxlength="250">

Exactly: we can't save it through htmlspecialchars() because it won't appear as HTML on threadpages, but an Administrator can enter that in their field and then it will work! But when you then try to look at the Edit Profile page, it gets messed up (due to the " in there).

I'll try and make a screenshot of it today, when I have the chance.

Tech_Koss
02-19-2002, 12:48 AM
i set custom title to "no" but now my members custom title are still there ...im using 2.2.2 if that help
can anyone help?

KuraFire
02-19-2002, 07:43 AM
If you've set the option "Use custom titles?" to NO after a few of them have given themselves a custom title, you'll have to reset those manually. I haven't seen any way to do this automatically... :(

JJR512
02-19-2002, 05:24 PM
In the admin cp, in the section on the left called "Import and Maintenance", there is a link to "Update Counters". Go there, and the very first thing you'll see you can do is "Update User's Titles". Try that.

Scrooge
02-21-2002, 07:00 PM
This is very close to what I am looking for on my board. In my case, I am trying to give contributors this option but not other users. Is there any way to make this available only to certain groups?

importmix
02-25-2002, 03:22 AM
Yeah, I just want my moderators to be able to do this. Not my regular users.

Mr. X
03-07-2002, 05:10 AM
Excellent hack, I installed it. I really needed something like this, but I have a question: How can I make it so that all custom titles are in a different color? Im playing around with some code:

<normalfont><b>$post[username]</b></normalfont><br>
<smallfont>$extratitle</smallfont>
<smallfont>$post[usertitle]</smallfont><br>

note -I put the custom titles on the bottom.

JJR512
03-07-2002, 05:40 AM
To change the color of only the custom title, do this. In the bit of code you add to functions.php, there is this line:
$extratitle="$post[field5]<br>";
Change it to this:
$extratitle="<font color=\"#FFFFFF\">$post[field5]</font><br>";
Of course, replace #FFFFFF with whatever color you want, using either the HTML #xxxxxx color codes, or an accepted named color.

Mr. X
03-07-2002, 05:51 AM
awesome. Worked like a charm. I was applying color code to the template and it changed all the little text in the user pane (which looked sorta kinda almost maybe cool). Thanks again!

Mr. X
03-07-2002, 06:07 AM
ooh ooh, just one more tiny thing: Is it possible to put "" around all custom titles automatically?

JJR512
03-07-2002, 06:21 AM
Yeah, in the same line, change $post[field5] to \"$post[field5]\"

Mr. X
03-07-2002, 06:29 AM
you are the man. :)

Chris M
06-04-2002, 08:41 PM
How would I add a THIRD Title set?

Would I add :

if ($post[field9]) {
$extratitle="$post[field9]<br>";
} else {
$extratitle="";
}

After

if ($post[field7]) {
if ($post[field8]) {
$extratitle="<div style=\"width:100%; filter:glow(color=$post[field8], strength=3)\">$post[field7]</div>";
} else {
$extratitle="$post[field7]<br>";
}
} else {
$extratitle="";
}

Also...When you have these added, can you have them so the user cannot edit them?

Satan

Chris M
06-04-2002, 08:52 PM
I figured it out...

You add :

if ($post[field9]) {
$extratitlea="$post[field9]<br>";
} else {
$extratitlea="";
}

After :

if ($post[field5]) {
if ($post[field6]) {
$extratitle="<div style=\"width:100%; filter:glow(color=$post[field6], strength=3)\">$post[field5]</div>";
} else {
$extratitle="$post[field5]<br>";
}
} else {
$extratitle="";
}

Then you add :

<smallfont>$extratitlea</smallfont>

to the Postbit template...

Satan

Smoothie
06-04-2002, 11:24 PM
Custom titles are still there even after updating the counters.

Chris M
06-05-2002, 12:43 AM
Huh?

Satan

Smoothie
06-05-2002, 12:51 AM
Custom titles set by the members. It should display "Member" and then the custom title under that, but it's not. It's only displaying the custom title set by the user. I went to my user cp and edited my profile, and added a custome title, now it displays correctly under my username, but no one elses.

Warlord
06-05-2002, 02:36 AM
*Hits the installed button*

:)

Smoothie
06-05-2002, 08:21 AM
Fixed the problem. For anyone that installed this hack, and had previosly allowed custom titles, and you still had members without the default titles under their username, even after updating the counters, and turning off "allow custom titles" in the admin cp, run this query:

Resetting Custom user titles to default:

UPDATE user SET customtitle = 0 WHERE usergroupid <> 6

Then run the user title update counters. Note this will reset everyone's title except admins.

Chris M
06-05-2002, 12:40 PM
Cool...

I finally understand what you mean!

Sweet...

Satan

Mr. X
09-06-2002, 01:37 AM
Im having a bit of a prob. A user of mine has a custom title, but its not showing up. Everyone else's though is just fine, except for him. Im wondering if the "UPDATE user SET customtitle = 0 WHERE usergroupid <> 6" command will fix this? I did have custom titles enabled on my forum before this hack, so I disabled that, updated counters and it worked, but for some reason now this 1 user doesnt have his title displayed. 2.2.6 here btw.

Mr. X
09-06-2002, 04:14 AM
Hmm, now it seems to effect a couple of users now. For example, 1 user has no title specified, so when I added one, it didnt display. However, I was able to modify the title of another user and it displayed fine.

Mr. X
09-07-2002, 09:16 AM
Anyone, Anyone? Bueller?

Mr. X
09-16-2002, 03:52 AM
....