By johnlinux on
Hi Forums,
I have the view below which lists terms in a vocabulary and displays their images using the taxonomy_view module. The problem comes when I post two video pages on a term, it displays the term twice on the result of this view. I dont know how to remove the duplicates and looks like the DISTINCT = YES option does not work.
Any ideas?
$view = new view;
$view->name = 'Video';
$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(
'name' => 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_taxonomy' => 1,
'exclude' => 0,
'id' => 'name',
'table' => 'term_data',
'field' => 'name',
'relationship' => 'none',
),
'tid' => 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,
'imagecache_preset' => 'Thumb',
'link_to_taxonomy' => 1,
'exclude' => 0,
'id' => 'tid',
'table' => 'term_image',
'field' => 'tid',
'relationship' => 'none',
),
'description' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 1,
'max_length' => '30',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'exclude' => 0,
'id' => 'description',
'table' => 'term_data',
'field' => 'description',
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'vid' => array(
'operator' => 'in',
'value' => array(
'21' => '21',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'vid',
'table' => 'term_data',
'field' => 'vid',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('title', 'Video Categories');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 15);
$handler->override_option('use_pager', '1');
$handler->override_option('distinct', 1);
$handler->override_option('style_plugin', 'grid');
$handler->override_option('style_options', array(
'grouping' => '',
'columns' => '3',
'alignment' => 'horizontal',
'fill_single_line' => 1,
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'video');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
Comments
the Views issue queue is a good place to look
If you have an issue with a module (Views), the issue queue is a good place to look:
http://drupal.org/project/issues/views?text=distinct&status=All&prioriti...
You can refine that search to better fit your situation, but reading through the results might help you find a solution. There are a lot of "issues" related to duplicates in Views displays, even if "distinct" is selected. I've experienced it, too, but last I tried, it was working in Drupal 6, at least for my use case and version of Views.
See you at the Drupalcon!
You can analyze the generated
You can analyze the generated SQL. It usually helps when something goes wrong. Try to run it in mysql client or phpmyadmin and see the result. :-)
thanks for the reply, i did
thanks for the reply, i did that and noticed there is a filter that could give better result. is there a way to edit the sql?
Altering the generated SQL in
Altering the generated SQL in Views is possible by implementing hook_views_query_alter(). However, Views provides several more hooks: http://drupalcontrib.org/api/drupal/contributions--views--docs--docs.php...
Never created a hook before
Never created a hook before looks like its time i learn how to. thanks