| « magpieRSS in b2evolution revisited |
This is another really long post but so what. Basically what I've done is made a little feed reader for b2evolution using magpieRSS and processing them a bit to display them on your blog. You will need three things to make this work: a b2evolution blog, magpieRSS, the little file I created, and a simple hack in your skin's _main.php file. Yeah I know - that's four things but deal with it. Oh and some feeds you want to read.
Hey keep in mind this is rev0 of a hack from a minor league script kiddie. I don't have any burning desire to implement this on my blog though I've got an idea for how I can use it on my club's web. I just thought it was cool stuff to tinker with so I did.
First go get magpieRSS and unzip it. You should have a folder with 3 other folders and 12 files in it.
EXTLIB (folder)
HTDOCS (folder)
SCRIPTS (folder)
AUTHORS
ChangeLog
CHANGES
cookbook
INSTALL
NEWS
README
rss_cache.inc
rss_fetch.inc
rss_parse.inc
rss_utils.inc
TROUBLESHOOTING
This is what I got from version .61 anyway. Future versions might have different stuff. Technically speaking you only need the EXTLIB folders and the four files with ".inc" extensions but it's only 106K so you might as well upload the whole thing to your b2evolution ../skins/skinname folder. You won't have to modify any of these files - just download, unzip, and upload them to your webspace. All the files with no extension can be opened with Wordpad or something like that. Great reading. Spell binding. Captivating. Can't wait for the movie.
Next you need to snag this file and save it as _magpierss.php in your ../skins/skinname folder. The top section is a bunch of fancy crap that I think mostly needs to be there but I also figured I could have some fun with.
The first part that does any work is the decoration section. I set them up in pairs because that's how they get used. H4 tags for each feed's site name, feed items are grouped as an Unordered List, and each item is a List Item. Set them up as you see fit to match your skin and your taste. EDIT: I just overhauled this file. There are a couple of more variables you can identify specific tags with. In some cases I coded a BR or a STRONG where you might not have wanted one so now you can leave it out. I also added a smattering of true/false variables to turn on or off some things like using the feed's title or linking to it if you use it. Finally I changed some of the variable names to (hopefully) make them a bit more intuitive.
The last bit is the actual guts of the hack. First it pulls the site name from the feed, links it to the site URI, and uses the site description for the link title attribute. It then takes each item's title and URI and description to create a linked title in bold and a truncated description. If the item has no title it will use part of the description. If the item has no URI it will use the site's URI. If the item description is really really long it will strip out html tags and display the first 374 characters. Why 374? Because my first car had a 374 cubic inch engine, my first girlfriend weighed 374 pounds, and my penis is 374 millimeters long. Or maybe just because. The file will also attempt to correct some bad xhtml that might be in your feed, though no guarantees of catching all of them.
Finally, you have to do a bit of hacking on _main.php in your skin. Somewhere in your sidebar section, which is normally at the end of _main.php, add this little bit of code.
The first bit is your div and class. I used the custom skin to test this so that's why I use bSideItem as the class name. Use whatever your skin uses. The first REAL bit is how magpieRSS gets called into action. It is not optional, unless you don't want it to work. I then put a nice little section heading in H3 size. You probably want to change that to something intelligent...
The four-line-block is where you say how many items from what feed you want displayed. You can repeat this sequence with as many feeds as you like, and you can "show_me" as many items per feed as you choose. You can also set it once and not bother with it again if you always want the same number of items displayed.
That's it! Future versions of this code will depend on what happens next, but I am thinking of making it run from a table that you administer from your back office. As I learn more about what magpieRSS can do I'll find new ways to process and display feeds, and as I play with more feeds I'll find new ways feeds can mess things up. I see no reason why feeds can be fully processed for inclusion as a post, or why processed feeds can't be regurgitated as a new feed. I'm also half way between here and a method to integrate this into the back office and get people out of the need to hack, but I got this feeling other people will be able to do a better quicker smarter job than me.
Oh yeah one more thing: you gotta have some feeds to read.
This is not a fucking tutorial you god damned cow!