Forum

Thread tagged as: Problem

RSS not picking up data

Hi,

I am sure I am not seeing the wood from the trees today, but I am trying to instal an RSS feed to monitor one of my multi-item regions.

My set-up is that I have created a new multi-item page using a master newsletter.php page.

This new page in the root is called summer-2014.php

So, following the 'How do I add an RSS feed to a news page?' example, I have created an rss.php file in the root of my site, next to my summer-2014.php page.

The summer-2014.php page contains:

<?php include(str_replace('/', DIRECTORY_SEPARATOR, 'admin/templates/pages/newsletter.php')); ?>

The rss.php page contains:

<?php include($_SERVER['DOCUMENT_ROOT'].'/admin/runtime.php'); ?>
<?php echo '<'.'?xml version="1.0"?'.'>'; ?>
<rss version="2.0">
<channel>
    <title>Article Title</title>
    <link>Article Link</link>
    <description>Article Description</description>
    <?php
        perch_content_custom('Articles', array(
                   'page'=>'/summer-2014.php',
                  'template'=>'_rss_item.html'
              )); 
       ?>
</channel>
</rss>

My _rss_item.html file is within the 'templates/content' folder and contains:

<item>
<title><perch:content id="articleTitle" type="text" label="Article Title:" /></title>
<link><a href="<perch:content id="_page" />?page=<perch:content id="count" />"></link>
<description>
    <![CDATA[
        <perch:content id="articleMainText" type="textarea" label="Article Main Body:" textile="true" />
    ]]>
</description>
</item>

Now what seems to be happening is that when I view the rss.php page in my browser, I do not return any content. My initial thought is, is it due to the page being dynamically created by the master newsletter.php file, but that just doesn't seem to make sense. But just wondered if the paths or something were getting mixed, as it is just not pulling in any data.

Grabbing at straws, but any advice would be great.

Thanks,

Andy

Andrew Kennedy

Andrew Kennedy 0 points

  • 7 years ago

Ok, I just had a further quick test on a few things and I could see that no content was being returned. However, by removing the line:

<?php echo '<'.'?xml version="1.0"?'.'>'; ?>

content is now pulled in. I forgot to say that I am running this on an XAMMP installation, so I will see if it works on the live server.

Apologies, I meant to say, that it will return content if I remove all the rss details, i.e. the rss.php file now looks like:

<?php include($_SERVER['DOCUMENT_ROOT'].'/admin/runtime.php'); ?>


    <?php
        perch_content_custom('Articles', array(
            'page'=>'/summer-2014.php',
            'template' => '_rss_item.html'
        ));
    ?>

I must be missing something.......

Drew McLellan

Drew McLellan 2638 points
Perch Support

What output do you get and how are you testing it?

Many browsers no longer support RSS.

Ahh, sorry I'm a bit late to this RSS game ! Client requested it and too be honest, I just jumped in with two feet.

My browser is Firefox 33. I am just literally opening my website at rss.php.

I quickly created a Yahoo account to see of it could be pulled in via this, but no joy....

Drew McLellan

Drew McLellan 2638 points
Perch Support

What output do you get?

No output when using the 'correct' rss file.

Well, the screen has a 'subscribe to this feed' box, but the template just renders the:

 <title>Article Title</title>
 <link>Article Link</link>
 <description>Article Description</description>

from the rss,php file, but the perch custom call returns no content.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is the page online somewhere I can see?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, that looks fine.

Yeah, I didn't think I was far off... Not sure why nothing is being returned though.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What do you mean nothing is returned? There's a couple of errors to sort out, but it's basically working:

https://validator.w3.org/feed/check.cgi?url=pelican.james-fisher.com%2Frss.php

Ok, for me, I am not seeing a listing of the title, article link, description etc.

Must be my browser set-up ?

Grrr, so frustraing. Just opened the page up in Chrome and I am getting the results.

Hmm, so sorry Drew, it looks like everything I had done WAS correct, just my set-up was poor. Cannot believe I spent all that time testing and trying things when it was just the browser. Lessons learned !

Thanks for all your help/

Sorry but it is concerning this. My link in the feed should have a format:

https://pelican.james-fisher.com/summer-2014.php?s=Nuclear-pond-clean-up-progresses

but instead is rendered as:

https://pelican.james-fisher.com/summer-2014.php?s=Nuclear%20pond%20clean-up%20progresses

Is there anyway I can stop the '-' becoming '%20'. I tried adding urlencode="true" into the link, but this just changes the '%20' into'+' signs.

Alternatively, is there a way in which I can tell perch to accept both types of URL, i.e. if it has dashes, plus signs or %20 ?

Ok, typed my issue to soon, too much stress and not enough coffee ! Found this little gem:

urlify="true"

I hope the above is useful to anyone.

Thanks,

Andy