diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index c5a8d372bd5d1ede512b9c93efce27feb29dcf25..04b3b78dacac190f9abb4b601913cc33383787bc 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -2178,7 +2178,7 @@ public function elementPreRender(array $element) { $element['#empty'] = $empty ? $view->display_handler->renderArea('empty', $empty) : array(); $element['#exposed'] = !empty($view->exposed_widgets) ? $view->exposed_widgets : array(); $element['#more'] = $view->display_handler->renderMoreLink(); - $element['#feed_icon'] = !empty($view->feed_icon) ? $view->feed_icon : array(); + $element['#feed_icons'] = !empty($view->feedIcons) ? $view->feedIcons : array(); if ($view->display_handler->renderPager()) { $exposed_input = isset($view->exposed_raw_input) ? $view->exposed_raw_input : NULL; @@ -2213,7 +2213,7 @@ public function elementPreRender(array $element) { $element['#pager'] = array(); $element['#footer'] = array(); $element['#more'] = array(); - $element['#feed_icon'] = array(); + $element['#feed_icons'] = array(); } $element['#rows'] = $form; diff --git a/core/modules/views/src/Plugin/views/display/Feed.php b/core/modules/views/src/Plugin/views/display/Feed.php index 7d1c5fef947e557ae45447c5b4aee1a0b6f94ffa..67171ab1c4650b7d03d2e8a81b8776749f1e3375 100644 --- a/core/modules/views/src/Plugin/views/display/Feed.php +++ b/core/modules/views/src/Plugin/views/display/Feed.php @@ -269,6 +269,9 @@ public function attachTo(ViewExecutable $clone, $display_id, array &$build) { $clone->buildTitle(); if ($plugin = $clone->display_handler->getPlugin('style')) { $plugin->attachTo($build, $display_id, $this->getPath(), $clone->getTitle()); + foreach ($clone->feedIcons as $feed_icon) { + $this->view->feedIcons[] = $feed_icon; + } } // Clean up. diff --git a/core/modules/views/src/Plugin/views/style/Opml.php b/core/modules/views/src/Plugin/views/style/Opml.php index 229e4c281be317fb499d69dfab83a8549cbe20b8..f41378f4111d6d10bf0e042898657f929288eec8 100644 --- a/core/modules/views/src/Plugin/views/style/Opml.php +++ b/core/modules/views/src/Plugin/views/style/Opml.php @@ -48,12 +48,11 @@ public function attachTo(array &$build, $display_id, $path, $title) { } } else { - $feed_icon = array( + $this->view->feedIcons[] = array( '#theme' => 'feed_icon', '#url' => $url, '#title' => $title, ); - $this->view->feed_icon = $feed_icon; } } diff --git a/core/modules/views/src/Plugin/views/style/Rss.php b/core/modules/views/src/Plugin/views/style/Rss.php index d40acf2f830ebb00dd0e4925ec565613637b42f0..f59711683d590f4c5e853fe49be41685e2aaf454 100644 --- a/core/modules/views/src/Plugin/views/style/Rss.php +++ b/core/modules/views/src/Plugin/views/style/Rss.php @@ -43,7 +43,7 @@ public function attachTo(array &$build, $display_id, $path, $title) { $url = _url($this->view->getUrl(NULL, $path), $url_options); // Add the RSS icon to the view. - $this->view->feed_icon = [ + $this->view->feedIcons[] = [ '#theme' => 'feed_icon', '#url' => $url, '#title' => $title, diff --git a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php index 7df3e31bc55de3d791e8b985a9b4e6cc87a6ddc1..97e6e996666796bca02268c92da605340c02eb1b 100644 --- a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php +++ b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php @@ -42,6 +42,7 @@ protected function setUp() { * Tests the rendered output. */ public function testFeedOutput() { + $this->drupalCreateContentType(['type' => 'page']); $this->drupalCreateNode(); // Test the site name setting. @@ -60,6 +61,17 @@ public function testFeedOutput() { $this->drupalGet('test-feed-display.xml'); $result = $this->xpath('//title'); $this->assertEqual($result[0], 'test_display_feed', 'The display title is used for the feed title.'); + + // Add a block display and attach the feed. + $view->getExecutable()->newDisplay('block', NULL, 'test'); + $display = &$view->getDisplay('feed_1'); + $display['display_options']['displays']['test'] = 'test'; + $view->save(); + // Test the feed display adds a feed icon to the block display. + $this->drupalPlaceBlock('views_block:test_display_feed-test'); + $this->drupalGet(''); + $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.'); } } diff --git a/core/modules/views/src/Tests/Wizard/BasicTest.php b/core/modules/views/src/Tests/Wizard/BasicTest.php index 7bb0f81481dbc695590ba0048e61f8b4b2b2d3a8..32f83c18f239836c0db31b07cf61355011b98e3a 100644 --- a/core/modules/views/src/Tests/Wizard/BasicTest.php +++ b/core/modules/views/src/Tests/Wizard/BasicTest.php @@ -74,6 +74,7 @@ function testViewsWizardAndListing() { $this->assertText($node2->label()); // Check if we have the feed. + $this->assertLinkByHref(_url($view2['page[feed_properties][path]'])); $elements = $this->cssSelect('link[href="' . _url($view2['page[feed_properties][path]'], ['absolute' => TRUE]) . '"]'); $this->assertEqual(count($elements), 1, 'Feed found.'); $this->drupalGet($view2['page[feed_properties][path]']); diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index fc32dc47c32105aca4805a4daaae1c9dcaae5d8e..9214808bdaf97b5cd6a4350e0e7960e4c9adc782 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -125,6 +125,13 @@ class ViewExecutable { */ public $attachment_after = array(); + /** + * Feed icons attached to the view. + * + * @var array + */ + public $feedIcons = array(); + // Exposed widget input /** diff --git a/core/modules/views/templates/views-view.html.twig b/core/modules/views/templates/views-view.html.twig index f839ef957218c7f93c9968a4e87b94bf41c3f9d8..46c7e0a0091c95a96408300dca39a80145ad37fc 100644 --- a/core/modules/views/templates/views-view.html.twig +++ b/core/modules/views/templates/views-view.html.twig @@ -20,7 +20,7 @@ * - empty: The content to display if there are no rows. * - pager: The optional pager next/prev links to display. * - exposed: Exposed widget form/info to display. - * - feed_icon: An optional feed icon to display. + * - feed_icons: Optional feed icons to display. * - more: An optional link to the next page of results. * - title: Title of the view, only used when displaying in the admin preview. * - title_prefix: Additional output populated by modules, intended to be @@ -85,9 +85,9 @@ {{ footer }} {% endif %} - {% if feed_icon %} -
- {{ feed_icon }} + {% if feed_icons %} +
+ {{ feed_icons }}
{% endif %}
diff --git a/core/modules/views/tests/modules/views_test_data/templates/views-view--frontpage.html.twig b/core/modules/views/tests/modules/views_test_data/templates/views-view--frontpage.html.twig index 0ccf2da9b39608aac0a534363ab50ea2b24dbb62..1d7ae512fa21041d92940e36991906197168cf18 100644 --- a/core/modules/views/tests/modules/views_test_data/templates/views-view--frontpage.html.twig +++ b/core/modules/views/tests/modules/views_test_data/templates/views-view--frontpage.html.twig @@ -20,7 +20,7 @@ * - empty: The content to display if there are no rows. * - pager: The optional pager next/prev links to display. * - exposed: Exposed widget form/info to display. - * - feed_icon: An optional feed icon to display. + * - feed_icons: Optional feed icons to display. * - more: An optional link to the next page of results. * - title: Title of the view, only used when displaying in the admin preview. * - title_prefix: Additional output populated by modules, intended to be @@ -80,9 +80,9 @@ {{ footer }} {% endif %} - {% if feed_icon %} -
- {{ feed_icon }} + {% if feed_icons %} +
+ {{ feed_icons }}
{% endif %}
diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 02e9f52307ecb01ce89420520b98394e832876d9..c216872bb5aa7ce91ddd98e26a1c8921bd830930 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -110,7 +110,7 @@ function views_theme($existing, $type, $theme, $path) { 'empty' => array(), 'exposed' => array(), 'more' => array(), - 'feed_icon' => array(), + 'feed_icons' => array(), 'pager' => array(), 'title' => '', 'attachment_before' => array(),