function Rss::attachTo
Same name in other branches
- 9 core/modules/views/src/Plugin/views/style/Rss.php \Drupal\views\Plugin\views\style\Rss::attachTo()
- 10 core/modules/views/src/Plugin/views/style/Rss.php \Drupal\views\Plugin\views\style\Rss::attachTo()
- 11.x core/modules/views/src/Plugin/views/style/Rss.php \Drupal\views\Plugin\views\style\Rss::attachTo()
File
-
core/
modules/ views/ src/ Plugin/ views/ style/ Rss.php, line 28
Class
- Rss
- Default style plugin to render an RSS feed.
Namespace
Drupal\views\Plugin\views\styleCode
public function attachTo(array &$build, $display_id, Url $feed_url, $title) {
$url_options = [];
$input = $this->view
->getExposedInput();
if ($input) {
$url_options['query'] = $input;
}
$url_options['absolute'] = TRUE;
$url = $feed_url->setOptions($url_options)
->toString();
// Add the RSS icon to the view.
$this->view->feedIcons[] = [
'#theme' => 'feed_icon',
'#url' => $url,
'#title' => $title,
];
// Attach a link to the RSS feed, which is an alternate representation.
$build['#attached']['html_head_link'][][] = [
'rel' => 'alternate',
'type' => 'application/rss+xml',
'title' => $title,
'href' => $url,
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.