Forum

Thread tagged as: Problem

Styling a Perch RSS Feed

Hi guys,

I'm trying to style an RSS feed on a website - it's not working, it's just rendering the style tags and code.

It's also not showing each individual post in the Chrome RSS Feeder app.

If I remove the header('Content-Type: application/rss+xml'); line, then it styles the page as expected, but then it doesn't even recognise it as a feed, but it does style the page.

Thanks, Harry

Harry Ray

Harry Ray 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You'll need to use an XML stylesheet - is that what you're doing?

Hi Drew,

I'm using a .xsl file - is that correct? see below for my rss.php code:

<?php include('../cms/runtime.php'); ?>
<?php 
    $domain = 'https://'.$_SERVER['HTTP_HOST'];
    PerchSystem::set_var('domain', $domain);

    header('Content-Type: application/rss+xml');

    echo '<?xml version="1.0"?'.'><?xml-stylesheet type="text/css" href="../css/feed.xsl" ?>'; 
?>
<rss version="2.0" xmlns:atom="https://www.w3.org/2005/Atom">
    <channel>
        <title>Active Gloucestershire Funding News</title>
        <link><?php echo PerchUtil::html($domain); ?>/news/</link>
        <description>Learn more about funding available for sport and physical activity in Gloucestershire. </description>
        <atom:link href="<?php echo PerchUtil::html($domain); ?>/news/funding_feed.php" rel="self" type="application/rss+xml" />
        <?php
            perch_blog_custom(array(
                'template'   => 'rss_post.html',
                'tag'        => 'funding',
                'sort'       => 'postDateTime',
                'sort-order' => 'DESC'
                ));
        ?>
    </channel>
</rss>
Drew McLellan

Drew McLellan 2638 points
Perch Support

I think that looks about right, yes.

It's not styling the feed though, unfortunately, so it's not quite right.

You can view the page here: https://activegloucestershire.org/news/funding_feed.php

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, but I don't think that's anything to do with the Perch side of things.

Do you have any tips as far as styling the feed goes?

Drew McLellan

Drew McLellan 2638 points
Perch Support

No my specialist subject, I'm afraid.