Commit f213f859 authored by alexpott's avatar alexpott

Issue #2251121 by olli, dawehner: Support to add a feed icon on pages with parameters

parent 14ae16ff
......@@ -265,6 +265,7 @@ public function attachTo(ViewExecutable $clone, $display_id, array &$build) {
// Defer to the feed style; it may put in meta information, and/or
// attach a feed icon.
$clone->setArguments($this->view->args);
$clone->setDisplay($this->display['id']);
$clone->buildTitle();
if ($plugin = $clone->display_handler->getPlugin('style')) {
......
......@@ -22,7 +22,7 @@ class DisplayFeedTest extends PluginTestBase {
*
* @var array
*/
public static $testViews = array('test_display_feed', 'test_attached_disabled');
public static $testViews = array('test_display_feed', 'test_attached_disabled', 'test_feed_icon');
/**
* Modules to enable.
......@@ -45,7 +45,7 @@ protected function setUp() {
*/
public function testFeedOutput() {
$this->drupalCreateContentType(['type' => 'page']);
$this->drupalCreateNode();
$node = $this->drupalCreateNode();
// Test the site name setting.
$site_name = $this->randomMachineName();
......@@ -74,6 +74,16 @@ public function testFeedOutput() {
$this->drupalGet('<front>');
$feed_icon = $this->cssSelect('div.view-id-test_display_feed a.feed-icon');
$this->assertTrue(strpos($feed_icon[0]['href'], 'test-feed-display.xml'), 'The feed icon was found.');
// Test feed display attached to page display with arguments.
$this->drupalGet('test-feed-icon/' . $node->id());
$page_url = $this->getUrl();
$icon_href = $this->cssSelect('a.feed-icon[href *= "test-feed-icon"]')[0]['href'];
$this->assertEqual($icon_href, $page_url . '/feed', 'The feed icon was found.');
$link_href = $this->cssSelect('link[type = "application/rss+xml"][href *= "test-feed-icon"]')[0]['href'];
$this->assertEqual($link_href, $page_url . '/feed', 'The RSS link was found.');
$feed_link = simplexml_load_string($this->drupalGet($icon_href))->channel->link;
$this->assertEqual($feed_link, $page_url, 'The channel link was found.');
}
/**
......
langcode: en
status: true
dependencies:
config:
- user.role.authenticated
module:
- node
- user
id: test_feed_icon
label: test_feed_icon
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: role
options:
role:
authenticated: authenticated
cache:
type: none
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: some
options:
items_per_page: 10
offset: 0
style:
type: default
row:
type: fields
fields:
title:
id: title
table: node_field_data
field: title
settings:
link_to_entity: false
plugin_id: field
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
filters: { }
sorts: { }
title: test_feed_icon
header: { }
footer: { }
empty: { }
relationships: { }
arguments:
nid:
id: nid
table: node_field_data
field: nid
relationship: none
group_type: group
admin_label: ''
default_action: ignore
exception:
value: all
title_enable: false
title: All
title_enable: false
title: ''
default_argument_type: fixed
default_argument_options:
argument: ''
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
items_per_page: 25
override: false
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
break_phrase: false
not: false
entity_type: node
entity_field: nid
plugin_id: numeric
display_extenders: { }
link_url: ''
link_display: page_1
cache_metadata:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- 'user.node_grants:view'
cacheable: false
feed_1:
display_plugin: feed
id: feed_1
display_title: Feed
position: 2
display_options:
display_extenders: { }
pager:
type: some
style:
type: rss
row:
type: node_rss
path: test-feed-icon/%/feed
displays:
default: default
page_1: page_1
cache_metadata:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- 'user.node_grants:view'
cacheable: false
page_1:
display_plugin: page
id: page_1
display_title: Page
position: 1
display_options:
display_extenders: { }
path: test-feed-icon/%
cache_metadata:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- 'user.node_grants:view'
cacheable: false
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment