Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.11
Component:
taxonomy data
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
19 Sep 2010 at 18:08 UTC
Updated:
20 Oct 2010 at 08:20 UTC
Hi,
I'm trying to create a block on every node page that lists the related terms to the category the node belongs to.
I have this so far:
$view = new view;
$view->name = 'related_terms';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'term_data';
$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('relationships', array(
'tid2' => array(
'label' => 'Related term',
'required' => 1,
'id' => 'tid2',
'table' => 'term_relation',
'field' => 'tid2',
'relationship' => 'none',
),
));
$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' => 'tid2',
),
));
$handler->override_option('sorts', array(
'name' => array(
'order' => 'ASC',
'id' => 'name',
'table' => 'term_data',
'field' => 'name',
'relationship' => 'tid2',
),
));
$handler->override_option('filters', array(
'vid' => array(
'operator' => 'in',
'value' => array(
'1' => '1',
),
'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('items_per_page', 0);
$handler->override_option('style_options', array(
'grouping' => '',
));
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
This does list related terms but it doesn't list the related terms of every node. I know I need to add an argument but I'm not sure what the argument should be?
Many thanks.
Comments
Comment #1
littlemisssunshine commentedSorry I meant to say the view doesn't list the related terms of the category each node belongs to.
Comment #2
littlemisssunshine commentedDoes anybody have any ideas?
Comment #3
esmerel commentedYou might want to look at views_attach - it might be more of what you're looking for; blocks don't take arguments as easily as other methods. You can also maybe try using terms by establishing their relationship to the nid from url?
Comment #4
littlemisssunshine commentedWhat's views_attach? Sorry to seem clueless, it's something I've never used before.
Comment #5
dawehnerGoogle is the key: http://drupal.org/project/views_attach
Comment #6
littlemisssunshine commentedThank you very much.