Recent Topics

1 Jul 27, 2005 12:05    

Hi all,

I've just installed the blog software and am enjoying it lots.

I have a question though. I have my blog installed and a page where people can reference it.

However, I'd like to take the latest entry from my blog and have it displayed on the home page of my web site.

Does anyone have any idea how I can do this?

thanks for your help

Jason

2 Jul 27, 2005 15:23

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.

3 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 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']

7 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 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 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 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


Form is loading...