[widget] Hot Topics

 
Post new topic   Reply to topic   printer-friendly view    b2evolution Forum Index -> Plugins & Extensions
View previous topic :: View next topic  
Author Message
mrxrsd
New Poster
New Poster

Joined: 14 Oct 2008
Posts: 3
add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Tue Oct 14, 2008 14:59    Post subject: [widget] Hot Topics Reply with quote

Topics order by clicks ( works with b2 2.4.5 )

Code:

<?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



?>


Last edited by mrxrsd on Tue Oct 14, 2008 20:50; edited 1 time in total
Back to top
View user's profile Send private message
mrxrsd
New Poster
New Poster

Joined: 14 Oct 2008
Posts: 3
add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Tue Oct 14, 2008 15:11    Post subject: Reply with quote

i will try to make more generic....if someone can help, pls post =)

Last edited by mrxrsd on Tue Oct 14, 2008 21:35; edited 1 time in total
Back to top
View user's profile Send private message
John
the uncertain

Joined: 22 Jun 2004
Posts: 2147
Reputation: 4.6Reputation: 4.6Reputation: 4.6Reputation: 4.6 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 27

PostPosted: Tue Oct 14, 2008 15:25    Post subject: Reply with quote

Looks good.
I disabled "smilies" in your code post.
Cheers

_________________
See the Sites in in Venice
Back to top
View user's profile Send private message Visit poster's website
mrxrsd
New Poster
New Poster

Joined: 14 Oct 2008
Posts: 3
add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Tue Oct 14, 2008 20:10    Post subject: Reply with quote

i didnt test for all b2 configs, so if u see anything strange, post a reply =)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    b2evolution Forum Index -> Plugins & Extensions All times are GMT - 5 Hours
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
b2evolution Support Forum RSS Feed Forums powered by php Bulletin Board