Skip to content

Instantly share code, notes, and snippets.

@rambuvn
Created February 18, 2014 04:43
Show Gist options
  • Save rambuvn/9064756 to your computer and use it in GitHub Desktop.
Save rambuvn/9064756 to your computer and use it in GitHub Desktop.
Experts list style like Designwall
<?php
/**
* Template Name: Experts List
*/
get_header(); ?>
<div id="content">
<?php while ( have_posts() ) : the_post(); ?>
<article <?php post_class(); ?>>
<header class="page-header">
<h1 class="page-title"><?php the_title(); ?></h1>
<?php $subtitle = rwmb_meta( 'nex_subtitle', 'type=text' ); echo $subtitle ? '<h2 class="sub-title">'.$subtitle.'</h2>' : ''; ?>
</header>
<div class="entry-content">
<div class="row">
<div class="span4">
<h5>Top experts last 7 days</h5>
<ul class="members-list">
<?php
$i = 1;
$users = dwqa_user_most_answer(10, strtotime('-7 days'));
foreach ($users as $user) {
if($user['post_author'] == 0) continue;
$user_info = get_userdata( $user['post_author'] );
echo '<li>';
if($i==1) { ?>
<div class="well">
<div class="clearfix">
<div class="user-avatar">
<?php echo get_avatar( $user_info->ID, 45 ); ?>
</div>
<div class="user-info">
<h5><a href="<?php echo bp_core_get_user_domain( $user_info->ID ); ?>"><?php echo $user_info->display_name; ?></a></h5>
<span class="activity"><?php echo $user['answer_count']; ?> answers last 7 days</span>
</div>
<div class="user-rank"><strong>1</strong><sup>st</sup></div>
</div>
<ul class="user-counting">
<?php
$question_count = dwqa_user_question_count($user_info->ID);
$answer_count = dwqa_user_answer_count($user_info->ID);
$comment_count = dwqa_user_comment_count($user_info->ID);
?>
<li><strong><?php echo $question_count; ?></strong> <span><?php echo ($question_count == 0) ? 'Question' : 'Questions'; ?></span></li>
<li><strong><?php echo $answer_count; ?></strong> <span><?php echo ($answer_count == 0) ? 'Answer' : 'Answers'; ?></span></li>
<li><strong><?php echo $comment_count; ?></strong> <span><?php echo ($comment_count == 0) ? 'Comment' : 'Comments'; ?></span></li>
</ul>
</div>
<?php } else { ?>
<div class="clearfix">
<div class="user-rank"><?php echo $i; ?></div>
<div class="user-avatar"><?php echo get_avatar($user_info->ID, 32); ?></div>
<div class="user-info">
<h5><a href="<?php echo bp_core_get_user_domain( $user_info->ID ); ?>"><?php echo $user_info->display_name; ?></a></h5>
<span class="activity"><?php echo $user['answer_count']; ?> answers last 7 days</span>
</div>
</div>
<?php }
echo '</li>';
$i++;
} ?>
</ul>
</div>
<div class="span4">
<h5>Top experts last 30 days</h5>
<ul class="members-list">
<?php
$i = 1;
$users = dwqa_user_most_answer(10, strtotime('-30 days'));
foreach ($users as $user) {
if($user['post_author'] == 0) continue;
$user_info = get_userdata( $user['post_author'] );
echo '<li>';
if($i==1) { ?>
<div class="well">
<div class="clearfix">
<div class="user-avatar">
<?php echo get_avatar( $user_info->ID, 45 ); ?>
</div>
<div class="user-info">
<h5><a href="<?php echo bp_core_get_user_domain( $user_info->ID ); ?>"><?php echo $user_info->display_name; ?></a></h5>
<span class="activity"><?php echo $user['answer_count']; ?> answers last 30 days</span>
</div>
<div class="user-rank"><strong>1</strong><sup>st</sup></div>
</div>
<ul class="user-counting">
<?php
$question_count = dwqa_user_question_count($user_info->ID);
$answer_count = dwqa_user_answer_count($user_info->ID);
$comment_count = dwqa_user_comment_count($user_info->ID);
?>
<li><strong><?php echo $question_count; ?></strong> <span><?php echo ($question_count == 0) ? 'Question' : 'Questions'; ?></span></li>
<li><strong><?php echo $answer_count; ?></strong> <span><?php echo ($answer_count == 0) ? 'Answer' : 'Answers'; ?></span></li>
<li><strong><?php echo $comment_count; ?></strong> <span><?php echo ($comment_count == 0) ? 'Comment' : 'Comments'; ?></span></li>
</ul>
</div>
<?php } else { ?>
<div class="clearfix">
<div class="user-rank"><?php echo $i; ?></div>
<div class="user-avatar"><?php echo get_avatar($user_info->ID, 32); ?></div>
<div class="user-info">
<h5><a href="<?php echo bp_core_get_user_domain( $user_info->ID ); ?>"><?php echo $user_info->display_name; ?></a></h5>
<span class="activity"><?php echo $user['answer_count']; ?> answers last 30 days</span>
</div>
</div>
<?php }
echo '</li>';
$i++;
} ?>
</ul>
</div>
<div class="span4">
<h5>Top experts of all times</h5>
<ul class="members-list">
<?php
$i = 1;
$users = dwqa_user_most_answer(10);
foreach ($users as $user) {
if($user['post_author'] == 0) continue;
$user_info = get_userdata( $user['post_author'] );
echo '<li>';
if($i==1) { ?>
<div class="well">
<div class="clearfix">
<div class="user-avatar">
<?php echo get_avatar( $user_info->ID, 45 ); ?>
</div>
<div class="user-info">
<h5><a href="<?php echo bp_core_get_user_domain( $user_info->ID ); ?>"><?php echo $user_info->display_name; ?></a></h5>
<span class="activity"><?php echo $user['answer_count']; ?> answers</span>
</div>
<div class="user-rank"><strong>1</strong><sup>st</sup></div>
</div>
<ul class="user-counting">
<?php
//$question_count = dwqa_user_question_count($user_info->ID);
//$answer_count = dwqa_user_answer_count($user_info->ID);
//$comment_count = dwqa_user_comment_count($user_info->ID);
?>
<li><strong><?php echo $question_count; ?></strong> <span><?php echo ($question_count == 0) ? 'Question' : 'Questions'; ?></span></li>
<li><strong><?php echo $answer_count; ?></strong> <span><?php echo ($answer_count == 0) ? 'Answer' : 'Answers'; ?></span></li>
<li><strong><?php echo $comment_count; ?></strong> <span><?php echo ($comment_count == 0) ? 'Comment' : 'Comments'; ?></span></li>
</ul>
</div>
<?php } else { ?>
<div class="clearfix">
<div class="user-rank"><?php echo $i; ?></div>
<div class="user-avatar"><?php echo get_avatar($user_info->ID, 32); ?></div>
<div class="user-info">
<h5><a href="<?php echo bp_core_get_user_domain( $user_info->ID ); ?>"><?php echo $user_info->display_name; ?></a></h5>
<span class="activity"><?php echo $user['answer_count']; ?> answers</span>
</div>
</div>
<?php }
echo '</li>';
$i++;
} ?>
</ul>
</div>
</div>
</article>
<?php endwhile; ?>
</div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment