[BLOCK] RSS Feed
 
Notifications
Clear all

[BLOCK] RSS Feed

3 Posts
1 Users
0 Reactions
1,853 Views
(@lyndsie)
Posts: 1263
Member Moderator
Topic starter
 

Description: Adds an RSS feed of your choice as a block. No hacking of files necessary.

Requirements: Works with 3.5.1. Probably works with earlier versions, though I haven't tested that.

Example: http://efictiontest.verilyviridian.com/index.php?skin=PhotoboothNEW

Download Link: http://www.verilyviridian.com/downloads/feed.zip

Simply download the .zip, unzip it, and follow the instructions in the README. Comments, questions, bugs, please post them here, or at my site, here: http://www.verilyviridian.com/efic/feed-block/

History:
V1.2 published 14 August 2009 - undoes v1.1 changes
v1.1 published 6 August 2009 - fixed item number discrepancy bug
v1 Published 4 August 2009


 
Posted : 06/08/2009 5:12 pm
(@lyndsie)
Posts: 1263
Member Moderator
Topic starter
 

There's a new version of the feed block up for download. The only thing that got changed was admin.php, so that's the only file that needs to be overwritten. Unless you never downloaded version 1.1. Then you're fine.

Basically I did something silly based on misinformation (I should have tested more thorougly...). The feed I was using at my test site had a space at the top, before all the feed items, and I thought it was a skinning thing. And I also thought that the feed was displaying one less than it should based on the admin input, even though I didn't remember it doing that before. As I now see, based on looking at the actual LJ comm in question, the space was from someone having a post with no title, and that space actually did count as an entry, so I reverted back to the previous, so essentially v1.2 = v1.  *headdesk*


 
Posted : 14/08/2009 6:42 pm
(@lyndsie)
Posts: 1263
Member Moderator
Topic starter
 

I thought I'd let all the users of this block in on some little tricks. There are a couple things that can be done to modify it, if you like.

Add descriptions

Change line 28 of feed/feed.php to this:


$content .= "t<a href=""$item[link"]">".$item['title']."</a><br />".$item['description']."n";

Original was this:


$content .= "t<a href=""$item[link"]">".$item['title']."</a><br />n";

What a description is can vary based on the RSS feed, so use with caution. You might get tons of text. There currently is no character limit, but you can decide whether or not to strip HTML. If you want to strip HTML tags coming in from the RSS feed, open lastrss.php and change $stripHTML to True (line 42). You probably should do this if you add the description.  Eventually I'll probably add all this to admin.php (including character limit on description) and a toggle to show/not show each description within the actual block itself.

Formatting the block

Of course, the block will be subject to whatever HTML/CSS you have wrapped around it. But should you want to make some formatting unique to this block, you can do that as well.

The section that deals with formatting the links is lines 26-30 of feed.php. (For any block, whatever is assigned to the $content variable is what will appear wherever {blockname_content} appears in a skin.)


   $content .= "<div>n";
   foreach($rs['items'] as $item) {
       $content .= "t<a href=""$item[link"]">".$item['title']."</a><br />n";
       }
   $content .= "</div>n";

As you can see, the first $content variable has a <div>. Simply add whatever class or id you like to that variable and you're good to go. NOTE: this is global. If you only want to change the formatting for one skin, make sure that the id or class only appears in that skin's style.css. If you want different formatting for different skins, you can add more divs. Just don't mess with the n, t, or quotes or any of that stuff and there shouldn't be any problems. (Do remember to also add corresponding </div> to the last $content.)

You may also be able to get the same effects by putting divs around {feed_content}, but I think if you're looking to modify stuff relevant to each item (like you could add <ul><li> stuff if you really wanted) you may have to do how I suggested. I haven't played with that much.


 
Posted : 04/09/2009 7:28 pm
Share: