Page 1 of 1

RSS feeding to an external index.php

Posted: Wed Jul 05, 2006 10:57 pm
by roloenusa
Hello,

I'm totally new to just about everything here.

Right now i'm trying to set up my site. I got Serendipity in the folder as it came. But i dont' wanna make it my front page. However, i'd like to feed my latest blog to the front page of the site.

I've been reading that you can do it through RSS + PHP which sounds like the way to go for me. However, I've been looking for instructions on how to do it everywhere and i can't find it.

I read the readme text doc that comes with the package, on how to feed it (although it wasn't as RSS) to a different page, but it was kind of confusing and after i tried a couple of times unsuccessfully, i gave up.

I was wondering if anyone could point me to a tutorial or plugging on how to feed RSS+PHP to my index.php on the root folder. (not the /serendipity folder).

Thank you so much for any help you guys can give me.

Re: RSS feeding to an external index.php

Posted: Thu Jul 06, 2006 11:06 am
by garvinhicking
Hi!

The faster (and more cooler way) would be to use the Serendipity framework instead of by using RSS.

Insert this piece of code into your startpage:

Code: Select all

<?php
chdir('serendipity'); // Or change this to the name of the directory where you installed s9y in!

# Include the s9y framework
include 'serendipity_config.inc.php';

# Initialize Template logic
serendipity_smarty_init();

# Fetch latest entries
$entries = serendipity_fetchEntries();

# Parses the latest entries
serendipity_printEntries($entries);

# Displays the latest entries template
$serendipity['smarty']->display(serendipity_getTemplateFile('entries.tpl', 'serendipityPath'));
chdir('..');
?>
Of course you could also create your own RSS feed parser using magiePRSS or Onyx, but that would be a tad harder if you are not skilled with PHP.

You might find tutorials for that by googling for "magpierss" and/or "Onyx" or simply "php display rss feed". This is unrealted to Serendipity, because the output logic needs to be your custom code; Serendipity just provides you the RSS/XML feed.

For an example on how to display RSS, the serendipity_plugin_remoterss plugin can show you how s9y does that. :)

HTH,
Garvin

Posted: Thu Jul 06, 2006 8:14 pm
by roloenusa
Thank you so much! your code worked perfectly well. I just have a quick question. Is there a way to manipulate the code so just the lastest RSS displays?

I'd like to set it up so just the latest one displays and probably the titles of the most recent ones.

But i'd settle for just the latest one.

If this is not possible with framework you gave me, then it's perfectly fine. I really apreciate your help. You have done an awesome job on this blog.

-S

Posted: Fri Jul 07, 2006 11:41 am
by garvinhicking
Hi!

Yes, you can limit the amount of fetched entries by changing:

Code: Select all

$entries = serendipity_fetchEntries(); 
to this:

Code: Select all

$entries = serendipity_fetchEntries(null, true, 10); 
This would then only display 10 entries.

Have fun with your blog, and please get back here if you have any more questions. :)

Best regards,
Garvin