Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-27-2011, 09:25 PM
waylandprod's Avatar
waylandprod waylandprod is offline
 
Join Date: Jan 2011
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Display User Number Images based on UserID

I'm working on a special configuration of our forum and running into a real pickle to figure out. My goal is to break down the user ID into individual numbers for PNG files. In other words user ID 183 would display 1.png, 8.png, 3.png.



I'm not sure how to set an if condition that would break down the Userid into those types of digits to be displayed and have it work for users 1 to 10,000.

I included a little bit of code that I was toying with, and I understand it doesn't work, but I was still trying.


Code:
UserID:
{vb:raw bbuserinfo.userid}


<img src="newartwork/numbers/3.png">

<vb:if condition="$bbuserinfo.userid == 1">
    <img src="newartwork/numbers/1.png">
</vb:if>
Reply With Quote
  #2  
Old 08-28-2011, 12:05 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There may be some way to do it with template conditionals but I think it would be difficult. The thing to do is use a plugin to calculate the file names:

PHP Code:
$userid $vbulletin->userinfo['userid'];
$images = array();
while (
$userid 0)
{
    
$images[] = $userid 10 '.png';
    
$userid intval($userid 10);
}
$images array_reverse($images);
vB_Template::preRegister('FORUMHOME', array('images' => $images)); 

and then in the template, something like:

Code:
<vb:each from="images" value="image">
<img src="newartwork/numbers/{vb:raw image}">
</vb:each>
Reply With Quote
  #3  
Old 08-28-2011, 05:49 PM
waylandprod's Avatar
waylandprod waylandprod is offline
 
Join Date: Jan 2011
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome thanks! I'll give that a try~
Reply With Quote
  #4  
Old 08-31-2011, 03:36 PM
waylandprod's Avatar
waylandprod waylandprod is offline
 
Join Date: Jan 2011
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What we ended up doing was just adding this to our header
HTML Code:
<div class="roomNumber">
<div class="roomslot" id="slot1"></div>
<div class="roomslot" id="slot2"></div>
<div class="roomslot" id="slot3"></div>
<div class="roomslot" id="slot4"></div>
<div class="roomslot" id="slot5"></div>

<script>
roomNumber="{vb:raw bbuserinfo.userid}";
slot1 = ('    ' + roomNumber).slice(-5,-4);
slot2 = ('    ' + roomNumber).slice(-4,-3);
slot3 = ('    ' + roomNumber).slice(-3,-2);
slot4 = ('    ' + roomNumber).slice(-2,-1);
slot5 = ('    ' + roomNumber).slice(-1);

document.getElementById('slot1').className += ' num'+slot1;
document.getElementById('slot2').className += ' num'+slot2;
document.getElementById('slot3').className += ' num'+slot3;
document.getElementById('slot4').className += ' num'+slot4;
document.getElementById('slot5').className += ' num'+slot5;
</script>
</div>
Then we have some CSS that displays the proper image per
Reply With Quote
  #5  
Old 08-31-2011, 03:53 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice - I hadn't thought of doing it in javascript. Thanks for posting that.
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 02:13 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.03953 seconds
  • Memory Usage 2,209KB
  • Queries Executed 11 (?)
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
  • (2)bbcode_code
  • (1)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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