Jump to content


Today's Top Posters

block

  • Please log in to reply
4 replies to this topic

#1 emoney emoney

emoney

    Administrator

  • Administrators
  • 1,091 posts

Posted 03 February 2012 - 07:11 PM

Add a "Today's Top Posters" block with the following settings (as of CSB 2.0).

This block requires some custom block templates, so first download this hook, extract it, and import the CSBMemberBlockTemplates.xml file from ACP->Manage Hooks:

Then create a new Custom Sidebar Block with the following data:

Name: Today's Top Posters
Enabled : Yes
Hide From Main Custom Block: Depends on where you want it
Full Image Name: users.png (or whatever you wish as long as it is in the proper directory and use reference it)
Enable RAW HTML/JS mode: No
Enable PHP Mode: Yes
Use Table/Border/Title/Image?: Yes
Remove Ability for User to Collapse Block? Up to you

Content:
$html = "";

/* INIT */
$time_high = time();
$rows = array();
$time_low = $time_high - (60*60*24);
$todays_post = 0;
$store  = array();
$mids  = array();
$justSayNo   = array();
$member_rows = "";

/* Re-moo-ve forums that do not allow incremental stuffywhasticmadoodah */
foreach( $this->registry->getClass('class_forums')->forum_by_id as $id => $data )
{
if ( ! $data['inc_postcount'] )
{
$justSayNo[] = $id;
}
}

$fiddyCent = $this->registry->getClass('class_forums')->fetchSearchableForumIds( $this->memberData['member_id'], $justSayNo );
$fiddyCent = ( count( $fiddyCent ) ) ? $fiddyCent : array( 0 => 0 );

/* Count posts today */
$total_today = $this->DB->buildAndFetch( array(
'select'   => 'count(*) as cnt',
'from'	 => array( 'posts' => 'p' ),
'where'	=> "p.post_date > {$time_low} AND t.forum_id IN(" . implode( ',', $fiddyCent ) . ')',
'add_join' => array( array( 'from' => array( 'topics' => 't' ),
'where' => 't.tid=p.topic_id',
'type' => 'left' ) ) ) );

/* Count member posts */
$this->DB->build( array('select' => 'COUNT(*) as tpost, p.author_id',
'from'   => array( 'posts' => 'p' ),
'where'  => "p.post_date > {$time_low} AND t.forum_id IN(" . implode( ',', $fiddyCent ) . ')',
'group'  => 'p.author_id',
'order'  => 'tpost DESC',
'limit'  => array( 0, 10 ),
'add_join' => array(  array( 'from'  => array( 'topics' => 't' ),
'where' => 't.tid=p.topic_id',
'type'  => 'inner' ) ) ) );
$this->DB->execute();

while( $r = $this->DB->fetch() )
{
$todays_posts += $r['tpost'];
$mids[ $r['author_id'] ] = $r['author_id'];

$store[] = $r;
}

if ( count( $mids ) )
{
$members = IPSMember::load( $mids );
}

/* Empty array for guests */
$members[0] = array();

if( $todays_posts )
{
foreach( $store as $info )
{
$info['total_today_posts'] = $todays_posts;

if ($todays_posts > 0 and $info['tpost'] > 0)
{
$info['today_pct'] = sprintf( '%.2f',  ( $info['tpost'] / $total_today['cnt'] ) * 100  );
}

$info = IPSMember::buildDisplayData( array_merge( $info, $members[ $info['author_id'] ] ) );

$extraData  = $this->registry->getClass('class_localization')->formatNumber( $info['tpost'] )." - ".$info['today_pct']."%";

$member_rows .= $this->registry->output->getTemplate('boards')->customSidebarBlockMemRow($info, $extraData);

$rows[] = $info;
}
}

if ( $member_rows )
{
$html .= $this->registry->getClass('output')->getTemplate('boards')->customSidebarBlockMem( $member_rows );
}

return $html;

Attached Files


DogPatch Was Here :D

#2 HaraldXP

HaraldXP

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 10 February 2012 - 06:28 PM

Looked a long time and now I've fount it? I Like it =)

#3 Stormchaser

Stormchaser

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 13 February 2012 - 08:23 AM

Parse error: syntax error, unexpected '[' in /home/codersco/public_html/admin/applications_addon/other/customSidebarBlocks/skin_cp/cp_skin_e_CSB.php(247) : eval()'d code on line 13

I get this error in my admin panel when I add the Todays top posters block I have made other blocks and this error does not happen.

Now I just noticed that I get the same error as above plus this one on the form index page

Warning: Cannot modify header information - headers already sent by (output started at /home/codersco/public_html/hooks/customSidebarBlocksHook_3c38f04abfe3878db64cbdcbe3d2be4c.php(56) : eval()'d code:13) in /home/codersco/public_html/admin/sources/classes/output/formats/html/htmlOutput.php on line 114

#4 emoney emoney

emoney

    Administrator

  • Administrators
  • 1,091 posts

Posted 13 February 2012 - 10:35 AM

When I edited the php code on the iPad it added bbcode tags for some reason, so if you got an eval() error that is why. The php code above has been fixed. :)
DogPatch Was Here :D

#5 Stormchaser

Stormchaser

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 13 February 2012 - 10:51 AM

Thank you it works perfectly now B)





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users