vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.8 Template Modifications (https://vborg.vbsupport.ru/forumdisplay.php?f=236)
-   -   Forum Display Enhancements - Custom Username colours (https://vborg.vbsupport.ru/showthread.php?t=220564)

shaunceb 08-09-2009 10:00 PM

Custom Username colours
 
1 Attachment(s)
This is my first posted template edit so be gentle.
It comes courtesy of the username and font hack by gio~logist.

This mod will allow you to define a list of colours for your users to pick from instead of them having to use hex codes. There is also the option of just letting particular user groups use this.

STEP 1

Goto User Profile Fields > Add new user profile field.

Select Single Selection Menu.

Title: Custom Username Colour
Description: Select a custom username colour.

Select your colours from the long list at http://www.w3schools.com/HTML/html_colornames.asp and enter them into the Options box. One colour per line.

Once you're done, save it and make a note of the field number

STEP 2

Edit your Postbit template.
Find

PHP Code:

div id="postmenu_$post[postid]">
                    <if 
condition="$show['profile']">
                    <
class="bigusername" href="member.php?$session[sessionurl]u=$post[userid]">$post[musername]</a>
                    
$post[onlinestatus]
                    <
script type="text/javascript"vbmenu_register("postmenu_$post[postid]"true); </script>
                    <else />
                    
$post[musername]
                    </if>
                </
div

and replace with
PHP Code:

<div id="postmenu_$post[postid]">
                    <if 
condition="$show['profile']">
                    <
class="bigusername" href="member.php?$session[sessionurl]u=$post[userid]">
<if 
condition="$post['fieldx'] != ''  ">
<
font style="color:$post[fieldx]">$post[musername]</font>
<else />
$post[musername]
</if>
</
a>
                    
$post[onlinestatus]
                    <
script type="text/javascript"vbmenu_register("postmenu_$post[postid]"true); </script>
                    <else />


                    
$post[musername]
                    </if>
                </
div

Change the x for your field id.


STEP 3

If you want to display this for certain usergroups;

Go to your Styles & Templates and select the userfield_select_option template.
Replace it with:

PHP Code:

<if condition="THIS_SCRIPT != 'profile' OR (!in_array($profilefield[profilefieldid], array(A, B, C)) OR is_member_of($bbuserinfo, 1, 2, 3))">
<
option value="$key$selected>$val</option>

</if> 

Change the A, B, C to your field id and the 1, 2, 3 to the usergroups you want to allow this for

Select the userfield_wrapper and replace that with the following:

PHP Code:

<if condition="THIS_SCRIPT != 'profile' OR (!in_array($profilefield[profilefieldid], array(A, B, C)) OR is_member_of($bbuserinfo, 1, 2, 3))">
<
fieldset class="fieldset">
    <
legend>$profilefield[title]</legend>
    
$custom_field_holder
</fieldset>


</if> 

Change the A, B, C to your field id and the 1, 2, 3 to the usergroups you want to allow this for

My coding abilities at best can be described as amateur but I'll try to help with any problems.

Mysterious2207 08-10-2009 10:02 AM

Pictures please.
This might be useful.

RileyFreeman 08-11-2009 11:27 AM

So I got it working, only problem like I said was the fact not all those colours will work. I will have to go through them to see which ones do and which ones don't. Also have to see what's the max amount of colours you can load. If you know please let me know.

Next are you able to add an option for the names to be in bold? In the screen print you will notice all names that have this are in bold.

shaunceb 08-11-2009 11:42 AM

Quote:

Originally Posted by RileyFreeman (Post 1865058)
So I got it working, only problem like I said was the fact not all those colours will work. I will have to go through them to see which ones do and which ones don't. Also have to see what's the max amount of colours you can load. If you know please let me know.


Next are you able to add an option for the names to be in bold? In the screen print you will notice all names that have this are in bold.

I would imagine the max number you can use is infinite and restricted by how many you actually want to use.


To make the names bold, just replace the first $post[musername] with <b>$post[musername]</b>

RileyFreeman 08-11-2009 12:00 PM

Awesome thanks man.

I think whoever does this we should compile a list of what colours work. This I think would be beneficial to everyone. I think we should compile the list and post here

KeyHunterz 08-11-2009 09:08 PM

nice hack, thanks alot !

RileyFreeman 08-11-2009 09:42 PM

One thing I noticed. My regular users are still able to do it, it just wont have any effect unless they purchase the paid subscription for it. Did I do it wrong or it is not setup for it to be hidden from them until they purchase a paid subscription

topranger 08-11-2009 10:16 PM

^ you have done this part wrong

PHP Code:

<if condition="THIS_SCRIPT != 'profile' OR (!in_array($profilefield[profilefieldid], array(A, B, C)) OR is_member_of($bbuserinfo, 1, 2, 3))">
<
option value="$key$selected>$val</option>

</if> 


RileyFreeman 08-11-2009 10:29 PM

Quote:

Originally Posted by topranger (Post 1865445)
^ you have done this part wrong

PHP Code:

<if condition="THIS_SCRIPT != 'profile' OR (!in_array($profilefield[profilefieldid], array(A, B, C)) OR is_member_of($bbuserinfo, 1, 2, 3))">
<
option value="$key$selected>$val</option>

</if> 




How do I fix it?

shaunceb 08-12-2009 07:28 AM

Quote:

Originally Posted by RileyFreeman (Post 1865452)
How do I fix it?

Find the userfield_wrapper template, delete the contents and paste this in. Replace the # with the profile id of your box and replace * with the usergroup of your paid subscribers.

PHP Code:

<if condition="THIS_SCRIPT != 'profile' OR (!in_array($profilefield[profilefieldid], array(#)) OR is_member_of($bbuserinfo, *))">
<
fieldset class="fieldset">
    <
legend>$profilefield[title]</legend>
    
$custom_field_holder
</fieldset>


</if> 

My bad for not paying attention. This is what you need.


All times are GMT. The time now is 05:46 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01091 seconds
  • Memory Usage 1,773KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete