Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Style-Specific Rank Images
Tanapangarap's Avatar
Tanapangarap
Join Date: Dec 2007
Posts: 80

 

California
Show Printable Version Email this Page Subscription
Tanapangarap Tanapangarap is offline 11-29-2009, 10:00 PM

As someone who used phpBB2 for the longest time, I was surprised to find that vBulletin 3x doesn't make the same accommodations for those who want to add style-specific rank images, or rank images that appear only for the style(s) you want. There was nothing in the "Mods" section that seemed to address the issue, and though there are plenty of requests to be found in the topics lists of vB org, vB com, and other vB sites, the most common answer is that it cannot be done (unless someone submitted a mod). A less frequent response, but the most promising one, is to use the Replacement Variable Manager in the AdminCP. Unfortunately, this method did not work for me. Also, some novice administrators may have trouble properly using replacement variables, as even seasoned vBulletin users acknowledge that it could be tricky.

That said, I discovered a method that I think is simpler, and I owe thanks to the user who submitted the helpful post I unexpectedly found in an only somewhat relevant topic from 2004. That post, "vBulletin.org Forum - View Single Post - Groupicons," informs the reader that, by inserting a certain code into the "postbit"?or "postbit_legacy", if user info is aligned to the left of each post? template, you can get any icon to appear based on what user group that member belongs to (e.g., Administrator, Moderator, Member, and etc).

Obviously, since the code is applied to the file ("postbit" or "postbit_legacy") of the one style, the image(s) you choose will only appear in that style. Anyways, here is that code:

Code:
<if condition="$post[usergroupid]==x"> IMG VAR HERE </if>
The person who provided this code said that "x" should be replaced by the user group ID (found in drop-down box in AdminCP > Usergroups). In addition, "IMG VAR HERE" should be replaced with the HTML for the image you want to display (more on that below).

Now, using the above code as my starting point, I took a look at the "postbit" template for my forum's default template, Enlighten. The point where the above code should be inserted is inline directly after this:

Code:
<if condition="$post['usertitle']"><div class="smallfont">$post[usertitle]</div></if>
                <if condition="$post['rank']"><div class="smallfont">$post[rank]</div>
As you know, that last line starting with "<if" and ending with "</div>" is what displays the text rank under your user name (and user title, if you have one). So here is how I modified the above code:

Code:
				<if condition="$post['usertitle']"><div class="smallfont">$post[usertitle]</div></if>
				<if condition="$post['rank']"><div class="smallfont">$post[rank]</div><if condition="$post[usergroupid]==6"><img src="enlighten/ranks/stars_orange.gif"/></if><if condition="$post[usergroupid]==5"><img src="enlighten/ranks/stars_red.gif"/></if><if condition="$post[usergroupid]==26"><img src="enlighten/ranks/stars_0.gif"/></if><if condition="$post[usergroupid]==15"><img src="enlighten/ranks/stars_1.gif"/></if><if condition="$post[usergroupid]==16"><img src="enlighten/ranks/stars_1.gif"/></if><if condition="$post[usergroupid]==17"><img src="enlighten/ranks/stars_2.gif"/></if><if condition="$post[usergroupid]==18"><img src="enlighten/ranks/stars_2.gif"/></if><if condition="$post[usergroupid]==19"><img src="enlighten/ranks/stars_3.gif"/></if><if condition="$post[usergroupid]==20"><img src="enlighten/ranks/stars_3.gif"/></if><if condition="$post[usergroupid]==21"><img src="enlighten/ranks/stars_4.gif"/></if><if condition="$post[usergroupid]==22"><img src="enlighten/ranks/stars_4.gif"/></if><if condition="$post[usergroupid]==23"><img src="enlighten/ranks/stars_5.gif"/></if></if>
That is taken from the Enlighten template. Here is how it looks on Greenfox, my other template, though:

Code:
				<if condition="$post['usertitle']"><div class="smallfont">$post[usertitle]</div></if>
                                <if condition="$post['rank']"><div class="smallfont">$post[rank]</div><if condition="$post[usergroupid]==6"><img src="images/greenfox/ranks/stars_orange.gif"/></if><if condition="$post[usergroupid]==5"><img src="images/greenfox/ranks/stars_red.gif"/></if><if condition="$post[usergroupid]==26"><img src="images/greenfox/ranks/stars_0.gif"/></if><if condition="$post[usergroupid]==15"><img src="images/greenfox/ranks/stars_1.gif"/></if><if condition="$post[usergroupid]==16"><img src="images/greenfox/ranks/stars_1.gif"/></if><if condition="$post[usergroupid]==17"><img src="images/greenfox/ranks/stars_2.gif"/></if><if condition="$post[usergroupid]==18"><img src="images/greenfox/ranks/stars_2.gif"/></if><if condition="$post[usergroupid]==19"><img src="images/greenfox/ranks/stars_3.gif"/></if><if condition="$post[usergroupid]==20"><img src="images/greenfox/ranks/stars_3.gif"/></if><if condition="$post[usergroupid]==21"><img src="images/greenfox/ranks/stars_4.gif"/></if><if condition="$post[usergroupid]==22"><img src="images/greenfox/ranks/stars_4.gif"/></if><if condition="$post[usergroupid]==23"><img src="images/greenfox/ranks/stars_5.gif"/></if></if>
Don't worry about using a "<br />" tag or equivalent, as the rank image will automatically place itself below the text rank, and there will be no added line brakes no matter how many rank images you add. Also, if you closely inspect the code, you'll notice that I made some of the rank image files repeat. The reason is this: for members, I have ten text ranks, but my rank images are five stars that fill up the more you post, so I want regular members to be promoted two ranks before receiving another star.

For use at your forum, just replace the usergroup IDs with yours, and replace the directories with the ones you use for each of your templates.

There you go: style-specific rank images. I have not tried it, but I wouldn't be surprised if you can even add more than one rank image for a given user group by placing additional image variables inside the conditional for that user group. In any case, please note that the rank image will not display below the text rank in the view member profile page (that is another edit).

By Kevin Malone of The Infinity Program.
Reply With Quote
  #2  
Old 05-31-2010, 05:28 AM
funmasti's Avatar
funmasti funmasti is offline
 
Join Date: Aug 2009
Location: World Wide Web
Posts: 108
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is "if Condition" add extra query to server? plz answer
Reply With Quote
  #3  
Old 06-03-2010, 02:01 AM
Tanapangarap's Avatar
Tanapangarap Tanapangarap is offline
 
Join Date: Dec 2007
Location: California
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No.

I tested this myself. Same amount of queries with or without.

-edit-

When applying style-specific rank images through the method I detailed above, the rank image would no longer display in the profile. I've figured out how to work around that: http://theinfinityprogram.com/showthread.php?t=3708
Reply With Quote
Reply


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 01:24 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.05620 seconds
  • Memory Usage 2,218KB
  • Queries Executed 18 (?)
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
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (2)postbit
  • (3)postbit_onlinestatus
  • (3)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