1
talunceford
User Rank

How would I go about displaying the user rank in a theme?

2
Mithrandir
Re: User Rank

I loathe <{php}> tags in themes, but either you should assign the user's rank in header.php or you can do it directly in the theme like this:
<{php}>
if (
$xoopsUser) {
    echo 
xoops_getrank($xoopsUser->getVar('rank'), $xoopsUser->getVar('posts') );
}
<{/
php}>


Naturally, if you do this in header.php, you just take the code to get the rank and assign it to a Smarty variable inside this code:
if ($xoopsUser != '') {
        
$xoopsTpl->assign(array('xoops_isuser' => true'xoops_userid' => $xoopsUser->getVar('uid'), 'xoops_uname' => $xoopsUser->getVar('uname'), 'xoops_isadmin' => $xoopsUserIsAdmin, [b]'user_rank' => xoops_getrank($xoopsUser->getVar('rank'), $xoopsUser->getVar('posts')[/b]));
        
$groups $xoopsUser->getGroups();
    } else {
        
$xoopsTpl->assign(array('xoops_isuser' => false'xoops_isadmin' => false));
        
$groups XOOPS_GROUP_ANONYMOUS;
    }

3
talunceford
Re: User Rank

You da man Mith! Thanks, I really appreciate it!!

Hopefully I can get this working tonight and let you guys see what I am doing to the bf2online theme. I think it will be pretty slick when I am done. Now I wish that my server would have rebooted when I told it to. Damn computers........ LOL

4
Mithrandir
Re: User Rank

Sorry - mistake on my part.

xoops_getrank() doesn't return a single value, but an array with the keys 'title' and 'image'

5
talunceford
Re: User Rank

Got it figured out. I added this code to the header.php file

//Added the rank assignments to Smarty Variables///////////////////////////////////////////////////////////////////////////
    
$thisUser =& $xoopsUser;
    
$userrank =& $thisUser->rank();
if (
$userrank['image']) {
    
$xoopsTpl->assign('xoops_rankimage''.XOOPS_UPLOAD_URL.'/'.$userrank['image'].'" alt="" />');
}
    
$xoopsTpl->assign('xoops_userrank'$userrank['title']);

6
talunceford
Re: User Rank

Well, I've been working on my bf2 site some more. This time, I've changed the header image for the site, and now have incorped the rank system into the header itself. Now when you hit the site, and you are an anon user, you don't see any changes persay in the graphics, but, if you were to register, and then login, your rank is now displayed, along with the corresponding header image in the upper left hand corner. Basically it looks at what your rank is called, say "Private" for example, and places the corresponding image in the header. I basically created 15 or so different images named the same thing as the rank, ie "Private.gif" etc. This way as soon as your rank changes, so does the image. Pretty slick I think...

You can check it out in action, by using the demo account. demo/demo

Thanks for looking, and keep on Xoopsing!!

http://www.bf2online.com

Login

Who's Online

332 user(s) are online (223 user(s) are browsing Support Forums)


Members: 0


Guests: 332


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits