XSL stylesheet¶
A feed implementation may return the path to an XSL stylesheet in the
getStyleSheet()
method. This way, the appearance of an Atom or RSS feed
can be customised in a browser.
EXT:your_extension/Classes/Feed/YourFeed.php
#[Feed('/your-feed.atom', FeedFormat::ATOM)]
final class YourFeed implements FeedInterface
{
public function getStyleSheet(): string
{
return 'EXT:your_extension/Resources/Public/Xsl/Atom.xsl';
}
// ... the other methods from the introduction example are untouched
}
Copied!
An XSL stylesheet is only considered for XML feeds (Atom and RSS). When providing a stylesheet for a JSON feed, it is ignored.
This extension comes with two XSL stylesheets, one for an Atom feed and one for an RSS feed, which can be used directly or copied and adapted to your needs:
- Atom:
EXT:feed_generator/Resources/Public/Xsl/Atom.xsl
- RSS:
EXT:feed_generator/Resources/Public/Xsl/Rss.xsl
Note
When adding an XSL stylesheet to an Atom or RSS feed, the content type of the
HTTP response is changed to application/xml
. This way Chrome and some other
browsers apply the stylesheet correctly.