View Single Post
  #1 (permalink)  
Old 08-27-2008, 02:54 PM
edmx edmx is offline
New Pligger
 
Join Date: Oct 2007
Posts: 5
Thanks: 0
Thanked 4 Times in 1 Post
Thumbs up Show Recent Visitors Avatar On SideBar

This one is a slight modification of this one [SOLVED] Top 5 users in sidebar

Basically, I didn't like to show Top 5 all the time. (Heck they could be dominating the top 5 forever). So instead I chose to have recent visitor. Here's how you do.

Create a new file: create a new file: /templates/templatename/sidebar_modules/sidebar_topuser.tpl

Code:
<div class="tlb">
<a href="topusers.php"><h2>Currently Online</h2></a></div>
<div>
	<ul style="list-style:none;">
		{php}
			global $db;
			$sql="SELECT user_login from " . table_users . " order by user_lastlogin desc limit 0,25";
			$result = @mysql_query ($sql);
			$rowCount = 0;
			while($row = mysql_fetch_array($result, MYSQL_ASSOC))
			{
				$uname=$row['user_login'];
				if (($rowCount++)%2 == 0)
					echo "<a href='" . getmyurl('user2', $uname, 'profile') . "'><img src='". get_avatar('large', "", "$uname","","")."' style='padding:0px 0px 3px 3px'></a>";
				else
					echo "<a href='" . getmyurl('user2', $uname, 'profile') . "'><img src='". get_avatar('large', "", "$uname","","")."' class='align-middle' style='padding:0px 0px 3px 3px'></a>";
			}
		{/php}
	</ul>
</div>
now edit templates\templatename/sidebar.tpl to include this line where ever you want the top users to get displayed:
{assign var=sidebar_module value="sidebar_topuser"}{include file=$the_template_sidebar_modules."/wrapper.tpl"}

You can have a look at Negaraku! for this mod (live).

I'm still unsure of how to make it look nicer or at least use proper CSS.

Code:
$sql="SELECT user_login from " . table_users . " order by user_lastlogin desc limit 0,25";
<< change 0,25 to any number you wish to show.

Don't ask me mysql or php question, I have very minimal knowledge on that area
Reply With Quote
The Following 4 Users Say Thank You to edmx For This Useful Post: