4
here is something similar I use that also shows if the user have new PMs:
<table id="topbar">
<tr>
<td class="headerlogin">
<{if $xoops_isuser}>
<{php}>
GLOBAL $xoopsUser;
$pm_handler =& xoops_gethandler('privmessage');
$uid = $xoopsUser->getVar('uid');
$criteria = new CriteriaCompo(new Criteria('read_msg', 0));
$criteria->add(new Criteria('to_userid', $uid));
$msgcount = $pm_handler->getCount($criteria);
$GLOBALS['xoopsTpl']->assign('msgcount', $msgcount);
<{/php}>
<{if $msgcount > 0}>
<a href="<{$xoops_url}>/viewpmsg.php"><img src="<{$xoops_imageurl}>images/prvmsg_on.jpg" alt=You have <{$msgcount}> new message />a>
<{else}>
<a href="<{$xoops_url}>/viewpmsg.php"><img src="<{$xoops_imageurl}>images/prvmsg_off.jpg" alt="You have no new messages" />a>
<{/if}>
<a href="<{$xoops_url}>/user.php" align="middle"><{$xoops_uname}>a> <a href="<{$xoops_url}>/user.php?op=logout"><img src="<{$xoops_imageurl}>images/exit_small.jpg" alt="EXIT" />a>
<{else}>
<form action="<{$xoops_url}>/user.php" method="post">
<img src="<{$xoops_imageurl}>images/username_small.jpg" alt="Username" />
<input name="uname" type="text" value="" size="14" />
<img src="<{$xoops_imageurl}>images/password_small.jpg" alt="Password" />
<input name="pass" type="password" value="" size="12" />
<input name="op" type="hidden" value="login" />
<input name="submit" type="submit" value="<{$smarty.const._LOGIN}>" />
form>
<{/if}>td>
<td class="headercenter">
<{if $xoops_isuser}><{else}>
<form action="<{$xoops_url}>/register.php" method="post">
<input name="submit" type="submit" value="<{$smarty.const._REGISTER}>" />
form>
<{/if}>td>
<td class="headersearch">
<form action="<{$xoops_url}>/search.php" method="post">
<a href="<{$xoops_url}>/search.php"><img src="<{$xoops_imageurl}>images/search_small.jpg" alt="Advanced Search" />a>
<input name="query" type="text" size="15" class="button" />
<input name="action" type="hidden" value="results" />
<input name="submit" type="submit" value="<{$smarty.const._SEARCH}>" />
form>td>
tr>
table>
you may need to change it here and there to fit your needs