Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
Trying to color everything, LOL Details »»
Trying to color everything, LOL
Version: , by snyx snyx is offline
Developer Last Online: Jan 2013 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 08-20-2002 Last Update: Never Installs: 0
 
No support by the author.

Okay, well im trying to colorize the thread starter in forumdisplay based on the usergroup that member is in. The original code in forumdisplay.php is this:
PHP Code:
#    if ($thread['postuserid']) {
#      $thread['postedby'] = "<a href=\"member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]\">$thread[postusername]</a>";
#    } else {
#      $thread['postedby'] = $thread[postusername];
#    } 
I commented that out, and using the utmost BASIC of my php knoleadge replaced it with this code:
PHP Code:
if ($userinfo['usergroupid'] == '6') {
    
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='#cc0000'><b><i>$thread[postusername]</i></b></font></a>";
}
else if (
$userinfo['usergroupid'] == '7') {
    
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='green'><b>$thread[postusername]</b></font></a>";
}
else if (
$userinfo['usergroupid'] == '5') {
    
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='green'><b>$thread[postusername]</b></font></a>";
}
else {
    
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='blue'>$thread[postusername]</font></a>";

but this only makes all the usernames blue, no matter what group they are in.. what am I doing wrong, a little kick in the right direction would be steller, thanks

-myles

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 08-20-2002, 02:38 AM
ZiRu$'s Avatar
ZiRu$ ZiRu$ is offline
 
Join Date: Jan 2002
Location: Manitoba, Canada
Posts: 520
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by snyx
if ($userinfo['usergroupid'] == '6') {
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='#cc0000'><b><i>$thread[postusername]</i></b></font></a>";
}
else if ($userinfo['usergroupid'] == '7') {
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='green'><b>$thread[postusername]</b></font></a>";
}
else if ($userinfo['usergroupid'] == '5') {
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='green'><b>$thread[postusername]</b></font></a>";
}
else {
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='blue'>$thread[postusername]</font></a>";
}
[/php]
TRY THIS.......i dont know ++++ so back it up....

PHP Code:
      if ($loggedin['usergroupid'] == and $highlightadmin) {
          
$username "<b><i><font color=red>$loggedin[username]</font></i></b>"// Color for Admin
      
} else if (($loggedin['usergroupid'] == 7) and $highlightadmin) {
          
$username "<b><font color=darkred>$loggedin[username]</font></b>"// Color for Supermod
      
} else if (($mod["$userid"]) and $highlightadmin) {
          
$username "<b><font color=green>$loggedin[username]</font></b>"// Color for Mod
      
} else {
        
$username "<font color=blue>$loggedin[username]</font>"// Color for normal Member or "Highlight Admin" is turned of
      

and change the values...usergroup ids, colors and ++++
Reply With Quote
  #3  
Old 08-20-2002, 11:17 AM
snyx's Avatar
snyx snyx is offline
 
Join Date: Oct 2001
Location: Vancouver (whistler.2010)
Posts: 556
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

grrrrrr no that didnt work.. huh
is there anyway I could establish the usercolor some other way.. and call it into the code.. like..
PHP Code:
#    if ($thread['postuserid']) {
#      $thread['postedby'] = "<a href="member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]">$thread[SPECIALpostusername]</a>";
#    } else {
#      $thread['postedby'] = $thread[SPECIALpostusername];
#    } 
Reply With Quote
  #4  
Old 08-20-2002, 01:10 PM
ZiRu$'s Avatar
ZiRu$ ZiRu$ is offline
 
Join Date: Jan 2002
Location: Manitoba, Canada
Posts: 520
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

why dont you install the colored ONLINE USERS Hack?

is that what your trying to do? or in the postbit too?
Reply With Quote
  #5  
Old 08-20-2002, 06:02 PM
snyx's Avatar
snyx snyx is offline
 
Join Date: Oct 2001
Location: Vancouver (whistler.2010)
Posts: 556
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

in forumdisplay.. so were talkin somthing completely different!
I tried all the whos online hacks, and users browsing format
Reply With Quote
  #6  
Old 08-20-2002, 07:56 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

it can't show another color than blue, becaue your variable $userinfo isn't defined in forumdisplay, so the script allways runs the else condition.

you have to add a query to get $userinfo, or it would be impossible:
PHP Code:
    if ($thread['postuserid']) {
$userinfo=$DB_site->query_first("SELECT username,usergroupid FROM user WHERE userid=".$thread['postuserid']);      
if(
$userinfo['usergroupid']==6$color="red";
elseif (
$userinfo['usergroupid']==5$color="green";
else 
$color="blue";

$thread['postedby'] = "<font color=".$color."><a href="member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]">$userinfo[username]</a></font>";
    

} else {
      
$thread['postedby'] = $thread[postusername];
    } 
i know the code is optimizable, because it added a lot of queries, but it should work..
Reply With Quote
  #7  
Old 08-20-2002, 10:14 PM
snyx's Avatar
snyx snyx is offline
 
Join Date: Oct 2001
Location: Vancouver (whistler.2010)
Posts: 556
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

EEP! 57 queries..
but yeah thx for the shot, but im still not getting any colorednames.. huh they just look normal as if the color wasnt working at all.

uhhhhh, damn.
Reply With Quote
  #8  
Old 08-20-2002, 10:30 PM
snyx's Avatar
snyx snyx is offline
 
Join Date: Oct 2001
Location: Vancouver (whistler.2010)
Posts: 556
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Xenon I was wrong, your code was right, you html just off, to colorize links you need to include the font next to the actaully text inside the hyperlink... I tweaked the code to get what I like, thx man, and thx for ur guys help

PHP Code:
if ($thread['postuserid']) {
$userinfo=$DB_site->query_first("SELECT username,usergroupid FROM user WHERE userid=".$thread['postuserid']);
if(
$userinfo['usergroupid']==6$special="<font color=#cc0000><b><i>";
elseif (
$userinfo['usergroupid']==5$special="<font color=green><b>";
elseif (
$userinfo['usergroupid']==7$special="<font color=green><b>";
else 
$special="<font color=blue>";

$thread['postedby'] = "<a href="member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]">$special $userinfo[username]</a></font>"
-Myles
Reply With Quote
  #9  
Old 08-21-2002, 03:58 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you can decreasing the ammount of queries by adding some sort of hashing:

instead of
PHP Code:
$userinfo=$DB_site->query_first("SELECT username,usergroupid FROM user WHERE userid=".$thread['postuserid']);
if(
$userinfo['usergroupid']==6$special="<font color=#cc0000><b><i>";
elseif (
$userinfo['usergroupid']==5$special="<font color=green><b>";
elseif (
$userinfo['usergroupid']==7$special="<font color=green><b>"
try to use this:
PHP Code:
if(!isset($userinfo[$thread[postuserid]])) $userinfo[$thread[postuserid]]=$DB_site->query_first("SELECT username,usergroupid FROM user WHERE userid=".$thread['postuserid']);
if(
$userinfo[$thread[postuserid]]['usergroupid']==6$special="<font color=#cc0000><b><i>";
elseif (
$userinfo[$thread[postuserid]]['usergroupid']==5$special="<font color=green><b>";
elseif (
$userinfo[$thread[postuserid]]['usergroupid']==7$special="<font color=green><b>"
should work, but not tested
Reply With Quote
  #10  
Old 08-21-2002, 04:25 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ignore that, why not just using a JOIN query

just find:
PHP Code:
$threads=$DB_site->query("
SELECT 
$dotuserid $votequery ".iif($foruminfo[allowicons],'icon.title as icontitle,icon.iconpath,','')."
    thread.threadid,thread.title,lastpost, forumid,pollid,open,replycount,postusername,postuserid,
    lastposter,thread.dateline,views,thread.iconid,notes,thread.visible,sticky,votetotal,attach
    FROM thread
    "
.iif($foruminfo[allowicons],'LEFT JOIN icon ON (icon.iconid = thread.iconid)','')."
    
$dotjoin
    WHERE 
$threadids
    ORDER BY sticky DESC, 
$sortfield $sqlsortorder
    "
); 
and replace it with:
PHP Code:
$threads=$DB_site->query("
SELECT 
$dotuserid $votequery ".iif($foruminfo[allowicons],'icon.title as icontitle,icon.iconpath,','')."
    thread.threadid,thread.title,thread.lastpost, forumid,pollid,open,replycount,postusername,postuserid,
    lastposter,user.usergroupid,thread.dateline,views,thread.iconid,notes,thread.visible,sticky,votetotal,attach
    FROM thread
    "
.iif($foruminfo[allowicons],'LEFT JOIN icon ON (icon.iconid = thread.iconid)','')."
    
$dotjoin
    LEFT JOIN user ON (thread.postuserid = user.userid)
    WHERE 
$threadids
    ORDER BY sticky DESC, 
$sortfield $sqlsortorder
    "
); 
then you could use $thread[usergroupid] in your if construction and save a lot of extra queries
Reply With Quote
Reply

Thread Tools

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 05:56 AM.


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.05291 seconds
  • Memory Usage 2,349KB
  • Queries Executed 23 (?)
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
  • (10)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)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_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