Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
  #1  
Old 06-16-2011, 05:21 AM
AK Houston's Avatar
AK Houston AK Houston is offline
 
Join Date: Jan 2011
Location: Texas
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default i need a developer/coder/sourcer's help

hello, i have a question on a system i'm trying to use.
its a vbulletin_musername i believe. i'm trying to get my gold member's to be able to change the color of their name excluding the usergroup.
I own vbulletin 4.1.4 and my site is akmods.net
there is this other site, thetechgame.com, which has a paid subscription called "gold member" which allows you to do the following:



which allows you to select the color of your username from a drop down menu.

thetechgame.com runs on a different forum software which i don't know. they could possibly be on vbulletin.

i want to be able for my gold members to select the color of their username without having to make a whole new usergroup so they can change their color via user id.

if this is possible, could someone please help me do it to my forum. thanks.

~ALSO~

i want to be able to make a usergroup with names that scroll marquee of different colors. an example is on the link as follows:

http://www.thetechgame.com/xKryptic

if someone knows a PhP code that can do that for a usergroup, that would be great if someone could help me!

thanks, Houston
Reply With Quote
  #2  
Old 06-16-2011, 04:06 PM
Sarteck's Avatar
Sarteck Sarteck is offline
 
Join Date: Mar 2008
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

On the hook fetch_musername, you could use something like:
PHP Code:
if (is_member_of($user$special_group))
{
  
$user['musername'] = '<span style="color:'.$my_special_color.'">'.$user['username'].'</span>';

If you had a special User Field that you created (Admin CP -> User Profile Fields -> Add User Profile Field), you could use that value for the colour like so:

PHP Code:
if (is_member_of($user$special_group))
{
  
$my_special_color $user['fieldXX'];
  
$user['musername'] = '<span style="color:'.$my_special_color.'">'.$user['username'].'</span>';

In some areas there fetch_musername() is called, it doesn't send the UserFields along with the UserInfo. So you might want to check to make sure the field exists on the array, first.

PHP Code:
if (is_member_of($user$special_group))
{
  if (!
array_key_exists('fieldXX'$user)) {$user fetch_userinfo($user['userid']);}
  
$my_special_color $user['fieldXX'];
  
$user['musername'] = '<span style="color:'.$my_special_color.'">'.$user['username'].'</span>';

(Note that if a User's Info is already in the userinfo cache, it will just fetch what's in the cache, but you probably won't run into that problem. If you do, that can be gotten around with an extra line or two of code, to unset that User's $usercache entry. Just post back if you have problems.)

You can specify a Default colour, in case one is not yet set for the user.

PHP Code:
if (is_member_of($user$special_group))
{
  if (!
array_key_exists('fieldXX'$user)) {$user fetch_userinfo($user['userid']);}
  
$my_special_color = ($user['fieldXX']) ? $user['fieldXX'] : $my_default_color;
  
$user['musername'] = '<span style="color:'.$my_special_color.'">'.$user['username'].'</span>';


Note, of course, that you will have to change fieldXX to whatever your field is, and set a value for $special_group. I do recommend that you use a User Profile Field, too, although you CAN make an extra field right on the user table. (That's actually what I did myself before I found out about user Profile Fields and felt dumb for doing so, heh.)

Post back if you have any questions or run into any problems.

--------------- Added [DATE]1308244982[/DATE] at [TIME]1308244982[/TIME] ---------------

Oh, as for that marquee, I have something similar, but it was a rainbow text I programmed for my members who want to act all gay.

Use the fetch_musername hook again, and this code:

PHP Code:
    $len 16;
    
$base='123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    
$max=strlen($base)-1;
    
$randstr='';
    
mt_srand((double)microtime()*1000000);
    while (
strlen($randstr)<$len+1) {$randstr .= $base[mt_rand(0,$max)];}
    
$user['musername'] = '
  <span id="spastic_username_container_'
.$randstr.'">' $user['username'] . '</span>
  <script type="text/javascript">
  set_as_spastic(document.getElementById(\'spastic_username_container_'
.$randstr.'\'),\''.$user['username'].'\');
  </script>'

That Random String bit is important because each place a name occurs has to have a random ID. Don't worry, though--it doesn't take a lot of processing power, even though it looks kind of complicated. XD

ALSO, you must enter the following javaScript into your headinclude template:

HTML Code:
<script type="text/javascript">

function set_as_spastic(el,name)
{
  var randid = 0;
  randid = Math.floor(Math.random() * 102400);
  //randid = randint(12);
  el.id = 'spastic_username_container_' + randid;
  spastic_Timer[randid] = 0;
  spastic_index[randid] = 0;
  spastic_letters[randid] = name.split("");
  setInterval("spastic_username("+randid+")", 50); 
}


function randint(len)
{
  var chars = "0123456789";
  if (!len) {len=8;}
  var randomstring = '';
  for (var i=0; i<len; i++)
  {
    var rnum = Math.floor(Math.random() * chars.length);
    randomstring += chars.substring(rnum,rnum+1);
  }
  return randomstring;
}


var spastic_Timer = new Array();
var spastic_index = new Array();
var spastic_letters = new Array();

function spastic_username(idstring)
{
  var colors = new Array('ff00ff', 'ff0099', 'ff0000', 'ff9900', 'ffff00', '99ff00', '00ff00', '00ff99', '00ffff', '0099ff', '0000ff', '9900ff');
  var bgcolors = new Array('880088', '880033', '880000', '883300', '888800', '338800', '008800', '008833', '008888', '003388', '000088', '330088');
  spastic_index[idstring]++;
  if (spastic_index[idstring] > colors.length-1) {spastic_index[idstring] = 0;}
  var temp_index = spastic_index[idstring];
  var output = '';
  for (var i=0; i<spastic_letters[idstring].length; i++)
  {
    if (temp_index > colors.length-1) {temp_index = 0;}
    output += '<span style="color:#'+colors[temp_index]+'; background-color:#'+bgcolors[temp_index]+';">' + spastic_letters[idstring][i] + '</span>';
    temp_index++;
  }
  document.getElementById('spastic_username_container_'+idstring).innerHTML = output;
}
</script>
Just change the values in the colors and bgcolors array in the JavaScript to however you want. The values I have in there now are rainbow-ish, but you can set them however you want. Tinker around with it and see how you like it.

--------------- Added [DATE]1308245060[/DATE] at [TIME]1308245060[/TIME] ---------------

Oh! One more thing... When you put that Script into your headinclude template, you might have to wrap <vb:literal></vb:literal> tags around it, due to the curly braces.
Reply With Quote
  #3  
Old 06-16-2011, 05:33 PM
AK Houston's Avatar
AK Houston AK Houston is offline
 
Join Date: Jan 2011
Location: Texas
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks man! Big help!
Reply With Quote
  #4  
Old 06-16-2011, 05:48 PM
Sarteck's Avatar
Sarteck Sarteck is offline
 
Join Date: Mar 2008
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No prob. :> I know how much members like them fancy names. XD
Reply With Quote
  #5  
Old 06-16-2011, 05:53 PM
AK Houston's Avatar
AK Houston AK Houston is offline
 
Join Date: Jan 2011
Location: Texas
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

whats the HTML markup for the marquee?

and when i do the profile field, what type of text box do i use?
Reply With Quote
  #6  
Old 06-16-2011, 06:02 PM
Sarteck's Avatar
Sarteck Sarteck is offline
 
Join Date: Mar 2008
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by AK Houston View Post
whats the HTML markup for the marquee?

PHP Code:
$user['musername'] = '
  <span id="spastic_username_container_'
.$randstr.'">' $user['username'] . '</span>
  <script type="text/javascript">
  set_as_spastic(document.getElementById(\'spastic_username_container_'
.$randstr.'\'),\''.$user['username'].'\');
  </script>'

That makes it so the SPAN element is "set as spastic," which is my way for saying it's set for the JavaScript to execute. :>

Quote:
Originally Posted by AK Houston View Post
and when i do the profile field, what type of text box do i use?
I'd use a Single-Selection Menu, but that's just my preference.
Reply With Quote
  #7  
Old 06-16-2011, 06:19 PM
AK Houston's Avatar
AK Houston AK Houston is offline
 
Join Date: Jan 2011
Location: Texas
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

do you think if i gave you developer for my forum for a couple of minutes you could do it for me? appreciation would be much given
Reply With Quote
  #8  
Old 06-16-2011, 08:05 PM
Sarteck's Avatar
Sarteck Sarteck is offline
 
Join Date: Mar 2008
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by AK Houston View Post
I be having a wee bit of trouble getting this part of his plugin to work, heh.

On the profile_fetch_profilefields hook, I have the following code:

PHP Code:

    
if ($profilefield['profilefieldid'] == '16')
    {
        
$startbox '<div style="border:1px solid #000000; margin:1px;padding:1px;"><h2>Gold Membership Extras</h2><br />';
        
$endbox '</div>';


        
$data unserialize($profilefield['data']);
        
$selectbits '';
        
$foundselect 0;
        foreach (
$data AS $key => $val)
        {
            
$key++;
            
$selected '';
            if (
$vbulletin->userinfo["$profilefieldname"])
            {
                if (
trim($val) == $vbulletin->userinfo["$profilefieldname"])
                {
                    
$selected 'selected="selected"';
                    
$foundselect 1;
                }
            }
            else if (
$profilefield['def'] AND $key == 1)
            {
                
$selected 'selected="selected"';
                
$foundselect 1;
            }
            
$templater vB_Template::create('userfield_select_option');
                
$templater->register('key'$key);
                
$templater->register('selected'$selected);
                
$templater->register('val'$val);
            
$selectbits .= $templater->render();
        }
        if (
$profilefield['optional'])
        {
            if (!
$foundselect AND (!empty($vbulletin->userinfo["$profilefieldname"]) OR $vbulletin->userinfo["$profilefieldname"] === '0'))
            {
                
$optional $vbulletin->userinfo["$profilefieldname"];
            }
            
$templater vB_Template::create('userfield_optional_input');
                
$templater->register('optional'$optional);
                
$templater->register('optionalname'$optionalname);
                
$templater->register('profilefield'$profilefield);
                
$templater->register('tabindex'$tabindex);
            
$optionalfield $templater->render();
        }
        if (!
$foundselect)
        {
            
$selected 'selected="selected"';
        }
        else
        {
            
$selected '';
        }
        
$show['noemptyoption'] = iif($profilefield['def'] != 2truefalse);
        
$templater vB_Template::create('userfield_select');
            
$templater->register('optionalfield'$optionalfield);
            
$templater->register('profilefield'$profilefield);
            
$templater->register('profilefieldname'$profilefieldname);
            
$templater->register('selectbits'$selectbits);
            
$templater->register('selected'$selected);
        
$custom_field_holder $templater->render();

        
$templater vB_Template::create($wrapper_template);
            
$templater->register('custom_field_holder'$custom_field_holder);
            
$templater->register('profilefield'$profilefield);
        
$returnval $startbox.$templater->render().$endbox;
//if ($vbulletin->userinfo['userid'] == 533) {die($returnval.'<!-- test -->');}
        
return $returnval;
    } 
Now, when I uncomment //if ($vbulletin->userinfo['userid'] == 533) {die($returnval.'<!-- test -->');}, I get the expected output--the field is wrapped in between my "$startbox" and "$endbox" values. However, left commented, there is nothing that gets changed.

Could someone maybe point out a mistake I might be making?
Reply With Quote
  #9  
Old 06-18-2011, 02:38 AM
Sarteck's Avatar
Sarteck Sarteck is offline
 
Join Date: Mar 2008
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Sarteck View Post
In some areas there fetch_musername() is called, it doesn't send the UserFields along with the UserInfo. So you might want to check to make sure the field exists on the array, first.

PHP Code:
if (is_member_of($user$special_group))
{
  if (!
array_key_exists('fieldXX'$user)) {$user fetch_userinfo($user['userid']);}
  
$my_special_color $user['fieldXX'];
  
$user['musername'] = '<span style="color:'.$my_special_color.'">'.$user['username'].'</span>';

If anyone happens to use this thread as a reference for anything, take note that I made a mistake here. Calling fetch_userinfo() inside of the fetch_musername hook is not a good idea. Instead, it should be written like this:

PHP Code:
if (is_member_of($user$special_group))
{
  if (!
array_key_exists('fieldXX'$user))
  {
    global 
$vbulletin;
    
$tempuser $vbulletin->db->query_first(sprintf("SELECT fieldXX FROM ".TABLE_PREFIX."userfield WHERE userid=%d",$user['userid']));
    
$user['fieldXX'] = $tempuser['fieldXX'];
  }
  
$my_special_color $user['fieldXX'];
  
$user['musername'] = '<span style="color:'.$my_special_color.'">'.$user['username'].'</span>';

Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:29 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.12207 seconds
  • Memory Usage 2,332KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_html
  • (9)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete