Saturday, October 10, 2009

MC Sidebar top users code two

Lets try that again;

In index.php, add the following code;


$user = new User;


$select = "SELECT user_id, COUNT(*) as count ";

$from_where = " FROM " . table_comments . ", " . table_users . " WHERE comment_user_id=user_id GROUP BY comment_user_id";

$order_by = " ORDER BY count DESC ";


$rows = $db->get_var("select COUNT(*) as count $from_where $order_by");

$users = $db->get_results("$select $from_where $order_by LIMIT 0, 5");

$users_table = '';


if ($users) {

foreach($users as $dbuser) {


$user->id=$dbuser->user_id;

$user->user_read();

$user->all_stats();


$main_smarty->assign('user_userlink', getmyurl("user", $user->username));

$main_smarty->assign('user_avatar', get_avatar('large', "", $user->username, $user->email));

//function get_avatar($size = "large", $avatarsource, $user_name = "", $user_email = "", $user_id=""){

$users_table .= $main_smarty->fetch(The_Template . "/topusers_data.tpl");



}

}


$main_smarty->assign('users_table', $users_table);


In the file templates/oioioi/topusers_data.tpl reduce the code to;


[tr]

[td][a href="{$user_userlink}"][img src="{$user_avatar}" align="absmiddle" /][/a][/td]

[/tr]


Finally in templates/oioioi/sidebar2.tpl add the following code;


[div class="links"]

[/div]


[div class="headline"]

[div class="sectiontitle"]Most Commented Users[/div]

[/div]

[div class="aboutcontent"]

{$users_table}

[/div]

[div class="links"]

[/div]


This may need further modification in order to fully incorporate CSS

No comments:

Post a Comment