1 jayzn Jul 27, 2005 12:05
3 jayzn Jul 27, 2005 17:25
Hi there,
I've installed Magpierss and have it more or less working, I just can't work out how to get the entire entry posted instead of just the title and a link.
This is the code I am using
<?
$url = 'myrsslink_here;
$rss = fetch_rss($url);
echo "Site: ", $rss->channel['title'], "<br>";
$item = $rss->items[0];
$title = $item[title];
$content = $item['content'];
$url = $item[link];
echo "<a href=$url>$title</a></li><br>";
echo "<a href=$url>$content</a></li><br>";
?>
Any ideas?
Cheers
Jason
4 personman Jul 27, 2005 17:49
Could you give the url of your magpierss file? I was looking at your feed and here's an idea. Instead of
$item['content']
try
$item['description']
or
$item['content:encoded']
5 jayzn Jul 27, 2005 19:01
the magpierss files are at http://www.stateofhypnosis/com/magpierss
the rss feed is at http://stateofhypnosis.com/blog/xmlsrv/rss2.php?blog=5
(I think I've got that right?).
Thanks
Jason
6 jayzn Jul 27, 2005 19:12
Using
$content = $item['description'];
works and posts the content. Is there anyway of formatting the content so it looks decent?
http://www.stateofhypnosis.com/index2.php is where it is displayed at the moment.
Cheers
Jason
7 personman Jul 27, 2005 20:37
Cool. We're almost there. Yeah, you can control how it's formatted.
Right now you have:
echo "<a href=$url>$title</a></li><br>";
echo "<a href=$url>$content</a></li><br>";
That's going to put the post as a link. There are two </li> tags. There might be some opening li tags somewhere else in the script that you need to get rid of, too. Just change that to make it look how you want.
8 jayzn Jul 28, 2005 10:50
Thanks for that.
What I can't seem to get it to do is recognise the paragraphing of the blog entry.
Instead of spaces between paragraphs it is just a big stream of text.
I can format the text as I want, but I'd like the get the paragraph spacing so it looks neat ;) I've put <p> tags in the blog itself though it doesn't appear to have translated them into the RSS feed.
Cheers
Jason
9 personman Jul 28, 2005 14:59
Ok, that's becuase you're using description. Look at your RSS feed and you'll see that the full text of the post is given twice. Once inside the <description> tags and once again inside <content:encoded>. The first one is text only, so no html tags will show up, including <p>. If you can make MagpieRSS use content:encoded rather than description, then your formatting should show up. Insetead of
$item['description']
use
$item['content:encoded']
10 jayzn Jul 28, 2005 18:53
Thanks for pointing me in the right direction
echo $item['content']['encoded'];
Appears to be the code that you need and then it works.
Thanks for your help :)
jason
As long as your home page ends in .php, not .html, you could do this. You have a couple of options. You could take the file summary.php that came with b2evolution and modify it to only show the latest post. Then you could do an include on it in your home page.
The second option would be to use something like [url=http://magpierss.sourceforge.net/]MagpieRSS[/url] to grab the latest post from your RSS feed and display it on your home page.