I'd like to request a "Most Popular Links" block. The only problem is that it'd be dependent on another module - probably stats. Also, you'd need a way to count how many times the link was clicked.

CommentFileSizeAuthor
#3 weblinks_by_hits.jpg172.57 KBunderpressure

Comments

underpressure’s picture

I have this by using views. http://www.ravalonline.com/weblinks (right sidebar). I'll tell you the settings if you are interested.

ThePiston’s picture

please do, i'm a Drupal noob

underpressure’s picture

StatusFileSize
new172.57 KB

Code form

  $view = new stdClass();
  $view->name = 'popular_weblinks';
  $view->description = 'Weblinks sorted by total page-views';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = FALSE;
  $view->page_title = 'All-time popular content';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'table';
  $view->url = 'popular/alltime';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '20';
  $view->menu = TRUE;
  $view->menu_title = '';
  $view->menu_tab = TRUE;
  $view->menu_tab_weight = '0';
  $view->menu_tab_default = FALSE;
  $view->menu_tab_default_parent = NULL;
  $view->menu_tab_default_parent_type = 'tab';
  $view->menu_parent_tab_weight = '0';
  $view->menu_parent_title = '';
  $view->block = TRUE;
  $view->block_title = '10 most viewed';
  $view->block_header = '';
  $view->block_header_format = '1';
  $view->block_footer = '';
  $view->block_footer_format = '1';
  $view->block_empty = '';
  $view->block_empty_format = '1';
  $view->block_type = 'list';
  $view->nodes_per_block = '10';
  $view->block_more = FALSE;
  $view->block_use_page_header = FALSE;
  $view->block_use_page_footer = FALSE;
  $view->block_use_page_empty = FALSE;
  $view->sort = array (
    array (
      'tablename' => 'node_counter',
      'field' => 'totalcount',
      'sortorder' => 'DESC',
      'options' => '',
    ),
  );
  $view->argument = array (
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => '',
      'handler' => 'views_handler_field_nodelink',
      'options' => 'link',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'weblinks',
),
    ),
    array (
      'tablename' => 'node',
      'field' => 'status',
      'operator' => '=',
      'options' => '',
      'value' => '1',
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node_counter, node);
  $views[$view->name] = $view;

screen shot attached with settings.

ThePiston’s picture

thanks so much - worked:
http://odsites.com/

One thing: it doesn't seem to be counting hits. I've been clicking on one link and that doesn't go higher in my list. Anything else I need to have turned on?

ThePiston’s picture

ok, I got it for all the other noobs - enable Stats module, then go to "Logs>Access Log Settings" and enable hits in there. Also, make sure you have the weblinks setting set to "nodes" and not "urls"... otherwise it won't count anything.

rmiddle’s picture

This sounds like a nice feature to add. Adding to my todo list.

Thanks
Robert

nancydru’s picture

Please don't make it dependent on Views though. The two sites I want to use Weblinks on the most don't have Views.

rmiddle’s picture

Although I want to have views integration I have no intention if making views a Dependence.

Thanks
Robert

nancydru’s picture

Good. This block will be much faster if done natively, and I believe this will be a relatively slow block as it is.

nancydru’s picture

Included in the patch in http://drupal.org/node/282480

nancydru’s picture

Status: Active » Patch (to be ported)

committed to 6.x

rmiddle’s picture

Status: Patch (to be ported) » Fixed
nancydru’s picture

Status: Fixed » Closed (fixed)
cakka’s picture

Can you give me how to do that ?
The steps, i am Newbie :)

Thanks

rmiddle’s picture

cakka,

It is built into 5.x-2.0. You have to have the core module stats enabled and use Node not url in the settings but once you have stats enabled a block should be there called popular. That all there is to it.

Thanks
Robert