1

I created a view which is supposed to list the 5 most popular stories on my site, so I sorted by node statistics: total views, and included several content types in filters. Only problem is the view only checks the stories in the first content type selected and ignores all the others. Is there something I am doing wrong?

Here is an export of the view:

$view = new view;
$view->name = 'popular';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'created' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'date_format' => 'small',
    'custom_date_format' => '',
    'exclude' => 0,
    'id' => 'created',
    'table' => 'node',
    'field' => 'created',
    'relationship' => 'none',
  ),
  'title' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'totalcount' => array(
    'order' => 'DESC',
    'id' => 'totalcount',
    'table' => 'node_counter',
    'field' => 'totalcount',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'news' => 'news',
      'story' => 'story',
      'opinion' => 'opinion',
      'video' => 'video',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => 'type_op',
      'label' => 'Node: Type',
      'use_operator' => 0,
      'identifier' => 'type',
      'optional' => 1,
      'single' => 1,
      'remember' => 0,
      'reduce' => 0,
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('items_per_page', 5);
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
  • Did you check multiple content types on your filter or add a filter for each content type? – Laxman13 Jul 13 '11 at 14:06
  • I checked multiple content types... – Jane Jul 13 '11 at 14:16
  • Are you sure it's not checking the other content types? Perhaps your top 5 happen to be that first content type. Sorry guessing here, but not much to work with – Laxman13 Jul 13 '11 at 14:25
  • That's also what I thought, so I just unchecked the first content type and left the others, and it displayed stories from the following content type only. – Jane Jul 13 '11 at 14:29
  • So after removing that first content type it still showed that type in the view? – Laxman13 Jul 13 '11 at 14:38
3

Make sure that Content view counting is enabled in the Access Log Settings (admin/reports/settings). If this isn't enabled all content views will be equal to 0.

Count content views

3

You might want to consider the radioactivity module Radioactivity module which gives a more accurate and relevant reflection on the current popular content on the site.

The problem with using total views is that over time, the oldest content will always appear at the top of the list as they've been around longer. Whereas with the radioactivity module, it uses a points system and radioactivity "halflife" to rank content. This way, it will give a true reflection of the current trends of your site.

There's a handy video here which explains it all.

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.