“Show Recent Posts” & Simple Pie issues
Posted: 21st October 2008 01:11 AM

Hi,

I’m new to RapidWeaver and this forum and was wondering if anyone here would be able to help with a probem I have. I’m a bit of a novice, however RW is just so easy that I had to have it! However, the problem…

I’m making our band site and wanted some static content on the home page and some dynamic stuff, such as latest news, blog entries, so when I saw “Show Recent Posts” snippet I was chuffed to bits!

Now I downloaded the “Show Recent Posts 2” snippet and followed the instructions. Downloaded and added SimplePie 1.1.1 as an asset to the page, created the cache inline (777), etc (I also ran the compatibility test, which returned that everything was okay with my host, PHP, cURL, etc).
However when I uploaded my site the recent posts was blank, just white space. I then uploaded the Simple Pie demo and I could read feeds from other sites (rss, atom, xml, etc) however it wouldn’t return my site feeds from my feed url, returning a “cURL Error 7: timeout”

I spoke with my host, “Heart Internet”, who said:

“We don’t allow scripts to make HTTP requests to the same server they’re running on. This measure is in place to prevent script errors/misconfigured scripts from causing a “loopback” effect, which would severely detriment the performance of our shared servers - affecting other customers.

Unfortunately this block can’t be raised for specific sites. I’d suggest seeing if there’s anyway to implement what you’re trying to do without HTTP callbacks. I apologise for the inconvenience.”

Okay, I thought, I’ll just burn the feed through feedburner and point to that instead as that isn’t on the server site (that may be a stupid thing to do, forgive me, is it?). However all I got returned was:

A feed could not be found at http://feeds.feedburner.com/fifthcircle

But I can point my browser at that URL and see them? I’m exhausted! (I owe my family 4 days of my life back!!!)

I tore all the site down and have now just got some simple code (below) that pulls my feedburner and the BBC’s feedburner. Mine returns the ‘no feeds’ error and the BBC’s displays correctly. <boggle>

<?php
error_reporting
(E_ALL);
// Make sure SimplePie is included. You may need to change this to match the location of simplepie.inc.
require_once('assets/simplepie.inc');

// We'll process this feed with all of the default options.
$feed = new SimplePie('http://feeds.feedburner.com/bbc'$_SERVER['DOCUMENT_ROOT''cache');
$feed->set_timeout(60);
// This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it).
$feed->handle_content_type();
echo 
$feed->error();
// Let's begin our XHTML webpage code.  The DOCTYPE is supposed to be the very first thing, so we'll keep it on the same line as the closing-PHP tag.
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
>

<
html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<
head>
    <
title>Sample SimplePie Page</title>
    <
meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</
head>
<
body>

    <
div class="header">
        <
h1><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a></h1>
        <
p><?php echo $feed->get_description(); ?></p>
    </
div>

    
<?php
    
/*
    Here, we'll loop through all of the items in the feed, and $item represents the current item in the loop.
    */
    
foreach ($feed->get_items() as $item):
    
?>

        
<div class="item">
            <
h2><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
            <
p><?php echo $item->get_description(); ?></p>
            <
p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
        </
div>

    
<?php endforeach; ?>

</body>
</
html>

RapidWeaver is set to publish php files, no XML declaration, code Tidied, the test pages are HTML pages, custom feed disabled, site URL as below , the assets are added and the cache is CHMOD 777.

I don’t have a .htaccess file on my host (should I? What would I put in it?!), it’s obviously a shared server and as far as I can tell PHP is delivered as cgi (as opposed to module).

Site: http://www.fifthcirclemusic.com/
RSS: http://www.fifthcirclemusic.com/blog/files/blog.xml
Feedburner: http://feeds.feedburner.com/fifthcircle

RW is great, you just can’t help loving the styling, ease of use, plug-ins etc, however I’m really getting hung up on this problem. I’d really like a static home page (that isn’t a Blog) but can be added to with dynamic content from the blog page!

Any help you could offer would be greatly appreciated and would save both my sanity and my marriage!

Thank You and apologies for the long post,

David

#1.  Posted: 08th January 2010 10:57 PM

Hey,

I’m having the same kinds of issues with the “Show Recent Posts 2” script.  I followed all instructions exactly and this is what comes up instead of the posts displaying properly:

‘; echo ‘
‘; echo ‘’; echo $item->get_title() . ‘’; echo ‘
‘; echo ‘
‘ . $item->get_date(’j M Y’) . ‘
‘; echo ‘
‘; echo shortdesc($item->get_description(), 150); // Change 150 to the length of your choice echo ‘’; echo ‘Read more.’ . ‘’; echo ‘
‘; echo ‘
‘; } ?>

Here is the code, which I edited according to the readme file:

Recent posts

<?php

function shortdesc($string, $length)
{

$suffix = '...';

$short_desc = trim(str_replace(array("\r","\n", "\t"), ' ', strip_tags(StupefyEntities($string))));

$desc = trim(substr($short_desc, 0, $length));

$lastchar = substr($desc, -1, 1);

if ($lastchar == '.' || $lastchar == '!' || $lastchar == '?') $suffix='';

$desc .= $suffix;

return $desc;
}

function StupefyEntities($s = '') {
$inputs = array('–', '—', '‘', '’', '“', '”', '…', '[', ']');
$outputs = array('-', '--', "'", "'", '"', '"', '...', '[', ']');
$s = str_replace($inputs, $outputs, $s);
return $s;
}

require_once('assets/simplepie.inc');

// Copy and past the URL of your RSS feed here (currently defaults to seyDesigns RSS feed)
$feed = new SimplePie('http://www.kevinhaganlaw.com/index/blog_files/blog.xml');

$feed->handle_content_type();

$new = array();

// to limit the number of posts that appear, add a number sequence like 0,5 between the brackets. This will get you 5 posts, 0,8 will get you 8, and so on…
foreach ($feed->get_items(0,5) as $item) {

// Calculate 7 days ago where 168 represents the hours, the rest is a bit of a mystery to me
$thisweek = time() - (168*60*60);

if ($item->get_date('U') > $thisweek) {

$new[] = $item;
}
}

foreach($new as $item) {
echo '<div class="blog-entry">';
echo '<div class="blog-entry-title">';
echo '[url=" . $item-<get_permalink() . " ]';
echo $item->get_title() . '[/url]';
echo '</div>';
echo '<div class="blog-entry-date">' . $item->get_date('j M Y') . '</div>';
echo '<div class="blog-entry-body">';
echo shortdesc($item->get_description(), 150); // Change 150 to the length of your choice
echo '[url=" . $item-<get_permalink() . " ]';
echo 'Read more.' . '[/url]';
echo '</div>';
echo '</div>';
}

?>

If someone could please help me with this one, I’d really appreciate it.  Thanks

#2.  Posted: 09th January 2010 09:33 AM

Are you using Stacks?

I’ve found that the easiest way to get an RSS feed onto a static page is to create a Stacks page, and then add the RSS feed via an RSS stack.

 Signature 

Angela Booth
Writing Genii

#3.  Posted: 09th January 2010 01:21 PM

Hi,

I’m not at my mac at the moment but that looks like the code you get in RW in preview. Have you tried up loading to the server? This script needs to run server side.

David

#4.  Posted: 09th January 2010 08:12 PM

So I tried what used to be the RSS Stack by Elixer, although it no longer exists.  It is now called Twitter Update and no longer seems to be able to do that.

I also have tried uploading it to the server several times and it is the same as it is in preview mode.

     
 
‹‹ Slogan txt linking      Hide pages from menus ››