Issue #3383219 by Lendude, greatmatter, HeikkiY, PapaGrande, hansfn: Views RSS Feed Fields adds <time> tag
(cherry picked from commit 2e94575d27
)
merge-requests/5943/head
parent
dca79fb044
commit
f7e93f2a9d
|
@ -136,7 +136,9 @@ class RssFields extends RowPluginBase {
|
||||||
$item->description = is_array($field) ? $field : ['#markup' => $field];
|
$item->description = is_array($field) ? $field : ['#markup' => $field];
|
||||||
|
|
||||||
$item->elements = [
|
$item->elements = [
|
||||||
['key' => 'pubDate', 'value' => $this->getField($row_index, $this->options['date_field'])],
|
// Default rendering of date fields adds a <time> tag and whitespace, we
|
||||||
|
// want to remove these because this breaks RSS feeds.
|
||||||
|
['key' => 'pubDate', 'value' => trim(strip_tags($this->getField($row_index, $this->options['date_field'])))],
|
||||||
[
|
[
|
||||||
'key' => 'dc:creator',
|
'key' => 'dc:creator',
|
||||||
'value' => $this->getField($row_index, $this->options['creator_field']),
|
'value' => $this->getField($row_index, $this->options['creator_field']),
|
||||||
|
|
|
@ -47,6 +47,20 @@ display:
|
||||||
plugin_id: field
|
plugin_id: field
|
||||||
entity_type: node
|
entity_type: node
|
||||||
entity_field: title
|
entity_field: title
|
||||||
|
created:
|
||||||
|
id: created
|
||||||
|
table: node_field_data
|
||||||
|
field: created
|
||||||
|
relationship: none
|
||||||
|
group_type: group
|
||||||
|
admin_label: ''
|
||||||
|
entity_type: node
|
||||||
|
entity_field: created
|
||||||
|
plugin_id: field
|
||||||
|
type: timestamp
|
||||||
|
settings:
|
||||||
|
date_format: custom
|
||||||
|
custom_date_format: 'Y-m-d'
|
||||||
body:
|
body:
|
||||||
id: body
|
id: body
|
||||||
table: node__body
|
table: node__body
|
||||||
|
@ -315,7 +329,7 @@ display:
|
||||||
link_field: view_node
|
link_field: view_node
|
||||||
description_field: body
|
description_field: body
|
||||||
creator_field: title
|
creator_field: title
|
||||||
date_field: title
|
date_field: created
|
||||||
guid_field_options:
|
guid_field_options:
|
||||||
guid_field: view_node
|
guid_field: view_node
|
||||||
guid_field_is_permalink: true
|
guid_field_is_permalink: true
|
||||||
|
|
|
@ -42,20 +42,23 @@ class RssFieldsTest extends ViewsKernelTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests correct processing of link fields.
|
* Tests correct processing of RSS fields.
|
||||||
*
|
*
|
||||||
* This overlaps with \Drupal\Tests\views\Functional\Plugin\DisplayFeedTest to
|
* This overlaps with \Drupal\Tests\views\Functional\Plugin\DisplayFeedTest to
|
||||||
* ensure that root-relative links also work in a scenario without
|
* ensure that root-relative links also work in a scenario without
|
||||||
* subdirectory.
|
* subdirectory.
|
||||||
*/
|
*/
|
||||||
public function testLink() {
|
public function testRssFields() {
|
||||||
// Set up the current user as uid 1 so the test doesn't need to deal with
|
// Set up the current user as uid 1 so the test doesn't need to deal with
|
||||||
// permission.
|
// permission.
|
||||||
$this->setUpCurrentUser(['uid' => 1]);
|
$this->setUpCurrentUser(['uid' => 1]);
|
||||||
|
|
||||||
|
$date = '1975-05-18';
|
||||||
|
|
||||||
$node = $this->createNode([
|
$node = $this->createNode([
|
||||||
'type' => 'article',
|
'type' => 'article',
|
||||||
'title' => 'Article title',
|
'title' => 'Article title',
|
||||||
|
'created' => strtotime($date),
|
||||||
'body' => [
|
'body' => [
|
||||||
0 => [
|
0 => [
|
||||||
'value' => 'A paragraph',
|
'value' => 'A paragraph',
|
||||||
|
@ -72,6 +75,7 @@ class RssFieldsTest extends ViewsKernelTestBase {
|
||||||
$output = $view->preview('feed_2');
|
$output = $view->preview('feed_2');
|
||||||
$output = (string) $renderer->renderRoot($output);
|
$output = (string) $renderer->renderRoot($output);
|
||||||
$this->assertStringContainsString('<link>' . $node_url . '</link>', $output);
|
$this->assertStringContainsString('<link>' . $node_url . '</link>', $output);
|
||||||
|
$this->assertStringContainsString('<pubDate>' . $date . '</pubDate>', $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue