Drupal Views-按多个分类术语过滤

时间:2011-09-23 16:07:06

标签: drupal views arguments taxonomy

我有一个View设置来显示特色文章节点。对于每个节点,有2个分类词汇表可供使用。第一个是'精选',术语为“是”;第二个是带有术语的“部分”:主页,信息,博客等。如果一个节点有术语是(特色词汇)和术语博客(部分词汇)那么如果你要浏览到域名/博客那么你会看到特色内容。

视图设置为接受url中的第一个参数,以确定您正在查看的站点的哪个部分(Views参数:Taxonomy term)。这可以按预期工作。

最后,我按节点类型(文章)过滤,然后按我的视图无法返回内容的分类词汇(特色)进行过滤。如果我删除了分类词汇过滤器,它会为每个部分正确显示,尽管它显示所有文章节点。

问题可能是争论和过滤器是不同的分类词汇吗?

这是SQL查询:

    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

以下是我的观点:

  $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('sorts', 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);

1 个答案:

答案 0 :(得分:0)

希望你有一个节点,其中包含来自两个词汇表的术语。 难以从出口视角解决它.. 你可以做的是提供sql查询,哪个视图生成检查或在此处发布..

相关问题