Kc
Aug 28th, 2011, 11:53 AM
Hello coders and web devs. Here's the current project going on in the 4.1.5 test style.
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.
http://www.zombiepodcast.com/forum/newartwork/numbers/1.pnghttp://www.zombiepodcast.com/forum/newartwork/numbers/8.pnghttp://www.zombiepodcast.com/forum/newartwork/numbers/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.
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>
I received this reply from another developer who was very gracious to give a tip of two:
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>
Any ideas on how to get this going? J0be comes back on Monday, so I'll ask him then as well. Cheers!
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.
http://www.zombiepodcast.com/forum/newartwork/numbers/1.pnghttp://www.zombiepodcast.com/forum/newartwork/numbers/8.pnghttp://www.zombiepodcast.com/forum/newartwork/numbers/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.
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>
I received this reply from another developer who was very gracious to give a tip of two:
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>
Any ideas on how to get this going? J0be comes back on Monday, so I'll ask him then as well. Cheers!