开发者

Drupal Views- Filtering by multiple taxonomy terms

I have a View set up to display featured Article nodes. For each node there are 2 taxonomy vocabs to use. The first is 'Featured' with a term 'Yes'; the second is 'Section' with terms: Home, Info, Blog etc. If a node has the term Yes (Featured vocab) and the term Blog (Section vocab) then if you were to browse to domain.com/blog then you would see that featured content.

The view is set up to accept the first argument in the url to determine which section of the site you are viewing (Views argument: Taxonomy term). This works as expected.

Lastly, I am filtering by node type (Article) and then the taxonomy vocab (Featured) which is where my view is failing to return content. If I remove the taxonomy vocab filter it displays correctly for each section although it is displaying all Article nodes.

Could the issue be that the argument and filter are different taxonomy vocabs?

Here's the SQL query:

    SELECT node.nid AS nid,
    node.type AS node_type,
    node.vid AS node_vid,
    node_data_field_article_images.field_article_images_data AS node_data_field_article_images_field_article_images_data,
    node.title AS node_title,
    node.created AS node_created
    FROM node node 
    LEFT JOIN content_field_article_images node_data_field_article_images ON node.vid = node_data_field_article_images.vid
    LEFT JOIN term_node term_node ON node.vid = term_node.vid
    LEFT JOIN term_data term_data ON term_node.tid = term_data.tid
    WHERE (node.status <> 0) AND (node.type in ('article')) AND (node_data_field_article_images.field_article_images_list <> 0) AND (term_data.vid in ('20')) AND (term_data.name = 'home')
    ORDER BY node_created DESC

Here's my view:

  $view = new view;
  $view->name = 'marquee_slideshow_dev';
  $view->description = 'Marquee on homepage and landing pages';
  $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(
    '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' => 0,
      'exclude' => 0,
      'id' => 'title',
      'table' => 'node',
      'field' => 'title',
      'relationship' => 'none',
      'override' => array(
        'button' => 'Override',
      ),
    ),
  ));
  $handler->override_option('so开发者_C百科rts', array(
    'created' => array(
      'order' => 'DESC',
      'granularity' => 'second',
      'id' => 'created',
      'table' => 'node',
      'field' => 'created',
      'relationship' => 'none',
    ),
  ));
  $handler->override_option('arguments', array(
    'name' => array(
      'default_action' => 'default',
      'style_plugin' => 'default_summary',
      'style_options' => array(),
      'wildcard' => 'all',
      'wildcard_substitution' => 'All',
      'title' => '',
      'breadcrumb' => '',
      'default_argument_type' => 'php',
      'default_argument' => '',
      'validate_type' => 'none',
      'validate_fail' => 'not found',
      'glossary' => 0,
      'limit' => '0',
      'case' => 'lower',
      'path_case' => 'lower',
      'transform_dash' => 1,
      'add_table' => 0,
      'require_value' => 0,
      'id' => 'name',
      'table' => 'term_data',
      'field' => 'name',
      'validate_user_argument_type' => 'uid',
      'validate_user_roles' => array(
        '2' => 0,
        '7' => 0,
        '8' => 0,
        '4' => 0,
        '6' => 0,
        '5' => 0,
      ),
      'relationship' => 'none',
      'default_options_div_prefix' => '',
      'default_argument_fixed' => '',
      'default_argument_user' => 0,
      'default_argument_image_size' => '_original',
      'default_argument_php' => '$path = explode(\'/\', drupal_get_path_alias($_GET[\'q\']));
  $is_front = $_GET[\'q\'] == \'<front>\' || $_GET[\'q\'] == variable_get(\'site_frontpage\', \'<front>\');
  $arg0 = arg(0);

  if ($is_front) {
    return \'home\';
  } else if ($arg0 = \'node\' && arg(1) != \'add\' && arg(2) != \'edit\' && arg(2) != \'delete\' && $path[0] != \'\') {
    return $path[0];
  }
  ',
      'validate_argument_node_type' => array(
        'activitystream' => 0,
        'image' => 0,
        'contenttab' => 0,
        'content_about_fedex_content_page' => 0,
        'content_about_fedex_home_page' => 0,
        'content_about_fedex_landing_page' => 0,
        'content_access_article' => 0,
        'content_access_article_index' => 0,
        'content_access_content_page' => 0,
        'content_access_landing_page' => 0,
        'content_block' => 0,
        'content_case_study' => 0,
        'content_document' => 0,
        'content_event' => 0,
        'content_executive_viewpoint' => 0,
        'content_feature' => 0,
        'content_fedex_fact' => 0,
        'content_fedex_video_page' => 0,
        'content_great_place_to_work' => 0,
        'content_location' => 0,
        'content_opco_overview' => 0,
        'content_our_commitment_content_p' => 0,
        'content_our_commitment_landing_p' => 0,
        'content_region_overview' => 0,
        'content_resources' => 0,
        'content_sag' => 0,
        'content_small_business' => 0,
        'page' => 0,
        'slideshow_image' => 0,
        'story' => 0,
      ),
      'validate_argument_node_access' => 0,
      'validate_argument_nid_type' => 'nid',
      'validate_argument_vocabulary' => array(
        '14' => 0,
        '18' => 0,
        '17' => 0,
        '11' => 0,
        '10' => 0,
        '15' => 0,
        '9' => 0,
        '3' => 0,
        '16' => 0,
        '8' => 0,
        '5' => 0,
        '2' => 0,
        '7' => 0,
        '19' => 0,
        '1' => 0,
        '12' => 0,
        '13' => 0,
      ),
      'validate_argument_type' => 'tid',
      'validate_argument_transform' => 0,
      'validate_user_restrict_roles' => 0,
      'image_size' => array(
        '_original' => '_original',
        'thumbnail' => 'thumbnail',
        'preview' => 'preview',
        'icon' => 'icon',
      ),
      'validate_argument_php' => '',
      'override' => array(
        'button' => 'Override',
      ),
    ),
  ));
  $handler->override_option('filters', array(
    'status' => array(
      'operator' => '=',
      'value' => '1',
      'group' => '0',
      'exposed' => FALSE,
      'expose' => array(
        'operator' => FALSE,
        'label' => '',
      ),
      'id' => 'status',
      'table' => 'node',
      'field' => 'status',
      'relationship' => 'none',
    ),
    'type' => array(
      'operator' => 'in',
      'value' => array(
        'article' => 'article',
      ),
      'group' => '0',
      'exposed' => FALSE,
      'expose' => array(
        'operator' => FALSE,
        'label' => '',
      ),
      'id' => 'type',
      'table' => 'node',
      'field' => 'type',
      'relationship' => 'none',
    ),
    'vid' => array(
      'operator' => 'in',
      'value' => array(
        '20' => '20',
      ),
      '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('empty_format', '3');
  $handler->override_option('items_per_page', 0);
  $handler->override_option('use_pager', 'mini');
  $handler->override_option('distinct', 0);
  $handler->override_option('style_options', array(
    'grouping' => '',
  ));
  $handler = $view->new_display('block', 'Home Page', 'block_1');
  $handler->override_option('block_description', '');
  $handler->override_option('block_caching', -1);


hope you have a node which has terms from both the vocabulary .. its difficult to solve it from exported view.. what you can do is provide the sql query which view is generating check it or post it over here..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜