Issue #2348007 by jibran, olli, marcus7777: Taxonomy term view needs status filter

8.0.x
Alex Pott 2014-11-19 11:40:15 +00:00
parent b0f2463942
commit 9ae8e2c86a
5 changed files with 79 additions and 4 deletions

View File

@ -95,9 +95,9 @@ display:
relationship: none
group_type: group
admin_label: ''
default_action: ignore
default_action: 'not found'
exception:
value: all
value: ''
title_enable: false
title: All
title_enable: true
@ -168,6 +168,42 @@ display:
default_group_multiple: { }
group_items: { }
plugin_id: language
status:
id: status
table: taxonomy_index
field: status
relationship: none
group_type: group
admin_label: ''
operator: '='
value: true
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: boolean
style:
type: default
options:

View File

@ -74,6 +74,12 @@ class TermStorageSchema extends SqlContentEntityStorageSchema {
'not null' => TRUE,
'default' => 0,
),
'status' => array(
'description' => 'Boolean indicating whether the node is published (visible to non-administrators).',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'sticky' => array(
'description' => 'Boolean indicating whether the node is sticky.',
'type' => 'int',
@ -90,7 +96,7 @@ class TermStorageSchema extends SqlContentEntityStorageSchema {
),
'primary key' => array('nid', 'tid'),
'indexes' => array(
'term_node' => array('tid', 'sticky', 'created'),
'term_node' => array('tid', 'status', 'sticky', 'created'),
),
'foreign keys' => array(
'tracked_node' => array(

View File

@ -214,6 +214,15 @@ class TermViewsData extends EntityViewsData {
),
);
$data['taxonomy_index']['status'] = [
'title' => t('Publish status'),
'help' => t('Whether or not the content related to a term is published.'),
'filter' => [
'id' => 'boolean',
'label' => t('Published status'),
'type' => 'yes-no',
],
];
$data['taxonomy_index']['sticky'] = [
'title' => t('Sticky status'),

View File

@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Tests;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\views\Views;
/**
* Ensure that data added as terms appears in RSS feeds if "RSS Category" format
@ -106,5 +107,27 @@ class RssTest extends TaxonomyTestBase {
// Test that the feed page exists for the term.
$this->drupalGet("taxonomy/term/{$term1->id()}/feed");
$this->assertRaw('<rss version="2.0"', "Feed page is RSS.");
// Check that the "Exception value" is disabled by default.
$this->drupalGet('taxonomy/term/all/feed');
$this->assertResponse(404);
// Set the exception value to 'all'.
$view = Views::getView('taxonomy_term');
$arguments = $view->getDisplay()->getOption('arguments');
$arguments['tid']['exception']['value'] = 'all';
$view->getDisplay()->overrideOption('arguments', $arguments);
$view->storage->save();
// Check the article is shown in the feed.
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$raw_xml = format_xml_elements([[
'key' => 'title',
'value' => $node->label(),
]]);
$this->drupalGet('taxonomy/term/all/feed');
$this->assertRaw($raw_xml);
// Unpublish the article and check that it is not shown in the feed.
$node->setPublished(FALSE)->save();
$this->drupalGet('taxonomy/term/all/feed');
$this->assertNoRaw($raw_xml);
}
}

View File

@ -162,6 +162,7 @@ function taxonomy_select_nodes($tid, $pager = TRUE, $limit = FALSE, $order = arr
$query->addTag('node_access');
$query->addMetaData('base_table', 'taxonomy_index');
$query->condition('tid', $tid);
$query->condition('status', NODE_PUBLISHED);
if ($pager) {
$count_query = clone $query;
$count_query->addExpression('COUNT(t.nid)');
@ -686,7 +687,7 @@ function taxonomy_build_node_index($node) {
if (!empty($tid_all)) {
foreach ($tid_all as $tid) {
db_merge('taxonomy_index')
->key(array('nid' => $node->id(), 'tid' => $tid))
->key(array('nid' => $node->id(), 'tid' => $tid, 'status' => $node->isPublished()))
->fields(array('sticky' => $sticky, 'created' => $node->getCreatedTime()))
->execute();
}