- b2evolution CMS Support Forums
- b2evolution Support
- Plugins & Extensions
- [widget] Hot Topics
1 mrxrsd Oct 14, 2008 21:59
Topics order by clicks ( works with b2 2.4.5 )
<?php
/**
* This file implements the xyz Widget class.
*
* This file is part of the evoCore framework - {@link http://evocore.net/}
* See also {@link http://sourceforge.net/projects/evocms/}.
*
* @copyright (c)2003-2008 by Francois PLANQUE - {@link http://fplanque.net/}
*
* {@internal License choice
* - If you have received this file as part of a package, please find the license.txt file in
* the same folder or the closest folder above for complete license terms.
* - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
* then you must choose one of the following licenses before using the file:
* - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
* - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
* }}
*
* @package evocore
*
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @author fplanque: Francois PLANQUE.
*
* @version $Id: _coll_tag_cloud.widget.php,v 1.8.2.1 2008/09/09 06:04:36 fplanque Exp $
*/
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
load_class( 'widgets/model/_widget.class.php' );
/**
* ComponentWidget Class
*
* A ComponentWidget is a displayable entity that can be placed into a Container on a web page.
*
* @package evocore
*/
class coll_hot_topics_Widget extends ComponentWidget
{
/**
* Constructor
*/
function coll_hot_topics_Widget( $db_row = NULL )
{
// Call parent constructor:
parent::ComponentWidget( $db_row, 'core', 'coll_hot_topics' );
}
/**
* Load params
*/
function load_from_Request()
{
parent::load_from_Request();
}
/**
* Get name of widget
*/
function get_name()
{
return T_('Hot Topics');
}
/**
* Get short description
*/
function get_desc()
{
return T_('Topics order by Clicks');
}
/**
* Get definitions for editable params
*
* @see Plugin::GetDefaultSettings()
* @param local params like 'for_editing' => true
*/
function get_param_definitions( $params )
{
$r = array_merge( array(
'title' => array(
'type' => 'text',
'label' => T_('Block title'),
'defaultvalue' => T_('Hot Topics'),
'maxlength' => 100,
),
'max_lines' => array(
'type' => 'integer',
'label' => T_('Max # of lines'),
'size' => 4,
'defaultvalue' => 10,
),
), parent::get_param_definitions( $params ) );
return $r;
}
/**
* Display the widget!
*
* @param array MUST contain at least the basic display params
*/
function display( $params )
{
$this->init_display( $params );
global $Blog;
if( empty($Blog) )
{
return;
}
global $DB;
$sql = 'SELECT hit_uri as url, evo_items__item.post_title as title, count( * ) AS count
FROM evo_hitlog, evo_useragents, evo_items__item
WHERE evo_hitlog.hit_agnt_ID = evo_useragents.agnt_ID
AND evo_hitlog.hit_uri = CONCAT("/",evo_items__item.post_urltitle)
AND hit_blog_ID ='. $Blog->ID.'
GROUP BY url, title
ORDER BY 3 DESC
LIMIT '.$this->disp_params['max_lines'] ;
$results = $DB->get_results( $sql, OBJECT, 'Get hot topics' );
if( empty($results) )
{
return;
}
$this->disp_title();
echo '<ul>';
foreach($results as $row){
echo '<li><a href=" '.substr($Blog->siteurl,0,strlen($Blog->siteurl)-1).$row->url.'">'.$row->title.'</a></li>';
}
echo '</ul>';
return true;
}
} //hot topics by mrxrsd
?>
3 john Oct 14, 2008 22:25
Looks good.
I disabled "smilies" in your code post.
Cheers
4 mrxrsd Oct 15, 2008 03:10
i didnt test for all b2 configs, so if u see anything strange, post a reply =)
i will try to make more generic....if someone can help, pls post =)