PDA


View Full Version : [Module] Customizable RSS feed module


Pages : [1] 2 3 4 5 6 7 8 9 10 11 12 13

Tom M
12-15-2005, 02:29 PM
This is the generic RSS feed module for CMPS 2.0 and vBulletin 3.5.2 and is a significant update from the original version.


What's New

For starters there's now only one php file to deal with as all of the configuration parameters are now controlled by editing the module via CMPS. All of the existing control is still available as is the ability to use plain or fancy formatting - including modifying the output via css.


Installation

Installing the module is as simple as using the vBa CMPS -> Download/Upload Module dialog. This will create everything that's needed to get started including 2 templates; adv_portal_rss and adv_portal_rssbits, and the rss_cmps2.php module.

Once the module has been uploaded use the vBa CMPS -> Edit Modules screen to customize the settings using the RSS Feed Options section. As a minimum it is necessary to specify the RSS Feed URL and the RSS Cache Directory. As noted in the help text the RSS Cache Directory must be world-writable (chmod 777) for things to work properly.

To create additional RSS feeds simply copy the existing module, rename it to something relevant and fill in the information about that feed. All the RSS feed modules may use the same cache directory, though you may have multiple directories if desired.


Getting fancy

The adv_portal_rssbits template makes use of css to format the title, category and description. By default these classes don't exist so the text will be displayed using whatever the defaults are. Below are some sample css definitions that may be added to the Additional CSS Definitions (located in ACP -> Style Manager -> (style) Main CSS) for your style.


.rsstitle { font: bold 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; color: #003366; }
.rsstitle a:link, .rsstitle a:visited, .rsstitle a:active { text-decoration: none; color: #003366; }
.rsstitle a:hover { text-decoration: none; color: #3964A8; }
.rssdesc {font: normal 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; }
.rsscat {font: bold 8pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; }



Advanced Usage

The Data qualification code may be used to filter out individual feed items if desired. Use the text box to enter the appropriate php code to evaluate the $rss_item data and return a 'true' or 'false' value according to whether the item should be displayed. To display all feed items leave this blank.

The Data modification code may be used to manipulate the $rss_item data however desired. For example, since the publication date for the item isn't normally shown by the template this information could be added to the beginning of the description if a publication date is part of the available information by using the following.


if ($rss_item['PUBDATE']) $rss_item['DESCRIPTION'] = vbdate($vbulletin->options['dateformat'], strtotime($rss_item['PUBDATE']), $vbulletin->options['yestoday']) . ' <span class="time">' . vbdate($vbulletin->options['timeformat'], strtotime($rss_item['PUBDATE'])) . '</span><br />' . $rss_item['DESCRIPTION'];


Likewise, if the descriptions are too long you might add code to trim the length and display a "... [more]" where the "[more]" has the link used in the title.

Enjoy!


Revisions

1/4/2006
1. Added support for having the feed area scrollable. This adds two new options to the module and also contains a revised adv_portal_rss template.

If you don't require scrollable support there's no need to download this update.

12/28/2005
1. Fixed a bug when the closing </image> tag had other tags following it.

To update replace the rss_cmps2.php file or uninstall and reinstall the module.

12/23/2005
1. Fixed a bug when using 'fancy' formatting and using the 'qualifier'.

To update replace the rss_cmps2.php module and the adv_portal_rssbits template.

12/20/2005
1. Modified the template such that the css classes are only used when using 'fancy' formatting.
2. Added an optional Icon ID that may be specified to prefix the title when using 'plain' formatting.


https://www.paypal.com/en_US/i/btn/x-click-but04.gif (https://www.paypal.com/xclick/business=support%40babblers%2eorg&item_name=Babblers%20Support%20Donation&no_shipping=0&no_note=1&tax=0&currency_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8)
PS - If you like this module and would like to make a donation you may do so via PayPal.

alicat
12-15-2005, 03:31 PM
Looks really exellent thankyou, i wondered, im using your original version (you know the trouble i had to get it working) ;) but it is working and it's a great mod, i understand why i was so frustrated before, the reason being that the module only shows about 70% of the time, a refresh will on occasion show the mod and thus null my fears about it not working :) would this new version enable me to play with the cache settings to show the mod 100% of the time? thanx again for this it's wonderfull and sorry for my hot headedness :(

-A

Tom M
12-15-2005, 04:07 PM
What I've found is that whether or not things display really depends on how reliable the site hosting the feed is. The code isn't real robust if it gets an error page instead of the rss data and thus it decides that there's nothing to show. When that happens to me I usually just go and look at the respective cache file to make sure what's in it before I go and delete it in order to force a reread of the feed and that usually clears it up. At least until the next time the feed has a hiccup.

EDIT: I've uploaded and updated version that's much more robust as far as error conditions are concerned.

alicat
12-15-2005, 08:25 PM
Fatal error: file_put_contents cannot write in file. in /modules/rss_cmps2.php on line 121

killed my entire front page...

-A

Tom M
12-15-2005, 08:31 PM
Fatal error: file_put_contents cannot write in file. in /modules/rss_cmps2.php on line 121

killed my entire front page...

-AThat may be caused by 2 things.

1. The directory you specified for the cache doesn't exist.
2. You don't have the correct permissions on the directory you specified for your cache.

The directory specified during the configuration process must already exist and it must be world-writable (chmod 777) for things to work.

On a side note, it's always a good idea to set the permissions so that only admins can see the module when first getting things going. That way if there's a hiccup nobody else is aware of it ;)

alicat
12-15-2005, 08:32 PM
i've deleted it...worried me for a minute as i have a busy site and this downtime is a pain, i' can see what it was trying to do, it did'nt overwrite when i imported and made an extra mod...anyways, i'll leave it...thaanx anyways, good for a fresh install maybe :) i should of done some small manual edits like you said

Tom M
12-15-2005, 08:34 PM
i cannot remove it, work my module backup...**** how do i remove this module? both are inactive, somethings really gone here...its ****ed my site....Did you alredy correct the other problem? See my previous post.

alicat
12-18-2005, 07:51 PM
Yes all correct, ive reverted back to the original which works fine, just need it to show 100% of the time tho :) it shows just about 50/50...:)

-A

Tom M
12-18-2005, 08:45 PM
Yes all correct, ive reverted back to the original which works fine, just need it to show 100% of the time tho :) it shows just about 50/50...:)

-A
As you might expect, it works fine for me. What's the url of the feed you are using?

geoff
12-18-2005, 09:11 PM
dang..i got a white index page with an error same as post 4.

using feed http://www.gamespot.com/misc/rss/gamespot_updates_news.xml

I will work on it more as I know it should work. I also have that "article bot" going and that seems to work

Tom M
12-18-2005, 09:14 PM
dang..i got a white index page with an error

using feed http://www.gamespot.com/misc/rss/gamespot_updates_news.xml
What's the error?

Make sure that you filled in the path to the cache directory and CHMOD it to 777.

geoff
12-18-2005, 09:22 PM
my path for the cache is /forums/articlebot/cache/

can i use this one? do i need the slash in the beginning? or end?
i really would like this to do a shacknews report but their rss xml doesnt seem to do a thing

Tom M
12-18-2005, 09:28 PM
my path for the cache is /forums/articlebot/cache/

can i use this one? do i need the slash in the beginning? or end?
i really would like this to do a shacknews report but their rss xml doesnt seem to do a thingYou need to specify the absolute path to the directory w/o the trailing slash. I have the link you used running fine on my site so once you clear up the cache issue you should be good to go.

geoff
12-18-2005, 09:53 PM
i really dont know what to do...when i set chmod to 777, my ftp proggy says it made it 777 but when i go back and check it says 755...grr. Im not sure what the error is now..

just for clarification, absoulte path is http://www.site.com/forum.... ?

Tom M
12-18-2005, 09:59 PM
i really dont know what to do...when i set chmod to 777, my ftp proggy says it made it 777 but when i go back and check it says 755...grr. Im not sure what the error is now..

just for clarification, absoulte path is http://www.site.com/forum.... ?You host may not allow you to set world-writable folders so you may need to contact them.

The path would be /home/yoursite/cache or whatever and not the url (http://www.yoursite.com/cache). It's a good idea to always place world-writable directories outside accessible space.

geoff
12-18-2005, 10:14 PM
yep...it's my "WONDERFUL" host...they changed some policy that you cant have 777 the beginning of this month..a lot of folks arent to happy

geoff
12-18-2005, 10:41 PM
ok...all good now..nothing that a good php script cant handle...still not happy with my host though...nice hack Tom!!

Tom M
12-18-2005, 11:45 PM
ok...all good now..nothing that a good php script cant handle...Glad you got it sorted out. I am curious how you fixed it though.

geoff
12-18-2005, 11:49 PM
I added a php script forcing the folder to become 777. Plus, i found a vaild shacknews rss deally to dsiplay "geek" news..hehe.

also, i forgot to add a "/" before my path of the cache folder

Tom M
12-18-2005, 11:51 PM
Ah, I thought you'd coded around it in the module somehow.

geoff
12-18-2005, 11:53 PM
Ah, I thought you'd coded around it in the module somehow.
oh no...im not a coder..heh.

Tom M
12-23-2005, 02:53 PM
A bug fix dealing with qualified data when using fancy formatting has been uploaded to the first post.

If you don't use both of these features then there's no need to upgrade.

dazzlin
12-23-2005, 05:22 PM
Wow! That was incredibly easy and worked perfectly! I am brand new to both vbulletin and vbadvanced, having installed both only yesterday. So, I've been confused about nearly everything, but this was a breeze. Many, many thanks. In fact, to thank you, I will head off to make a donation right now.

Tom M
12-23-2005, 05:55 PM
Easy is the only way to go! Glad you liked it.

Bluestrike2
12-24-2005, 08:59 PM
Got the following error:

Warning: file_get_contents(feed://feeds.feedburner.com/mlgpwncast): failed to open stream: No such file or directory in /modules/rss_cmps2.php on line 157

Warning: file_get_contents(feed://feeds.feedburner.com/mlgpwncast): failed to open stream: No such file or directory in /modules/rss_cmps2.php on line 217

Warning: file_get_contents(feed://feeds.feedburner.com/mlgpwncast): failed to open stream: No such file or directory in /modules/rss_cmps2.php on line 217

Warning: file_get_contents(feed://feeds.feedburner.com/mlgpwncast): failed to open stream: No such file or directory in /modules/rss_cmps2.php on line 217

Warning: file_get_contents(feed://feeds.feedburner.com/mlgpwncast): failed to open stream: No such file or directory in /modules/rss_cmps2.php on line 217

I know its the holidays, and I know you're busy but if you're willing to help me whenever you get a chance I'd very much appreciate it!

Tom M
12-24-2005, 09:28 PM
Changing the url from

feed://feeds.feedburner.com/mlgpwncasttohttp://feeds.feedburner.com/mlgpwncast

Merry Christmas

PS: if the url doesn't work in a browser it won't work in the script. I got errors using 'feed:' in both FF and IE.

alicat
12-26-2005, 10:08 PM
http://www.sgurl.org/ (check on right "Gallery Latest" when portal loads for your rss feed mod) which comes from here (http://www.sgurl.org/gallery/rss.php?type=rss) as i say on 50% shows...

-A

Tom M
12-27-2005, 01:31 AM
http://www.sgurl.org/ (check on right "Gallery Latest" when portal loads for your rss feed mod) which comes from here (http://www.sgurl.org/gallery/rss.php?type=rss) as i say on 50% shows...

-A
Since you need to be a registered member to see the gallery content there's not much I can do.

alicat
12-27-2005, 12:52 PM
Well the rss module is displayed to unregistered members, also unregistered members can view the gallery (thumbs only) i dont think a registration (which you can do simply) would acheive much here, unless im wrong, please clarify...

-A

Tom M
12-27-2005, 01:38 PM
I tried this just now and the rss feed supplied via the link is working for me. The image is there in its entirety but the cell it's in is too wide. In this case it appears the problem has more to do with the HTML in the feed than the module used to display it.

euangel
12-28-2005, 02:31 PM
I'm getting no love on this...the module isn't even showing up. I have vb3.5 and vbacmps 2.0. The module is set to active, but it just doesn't appear. I'm sure I'm overlooking something simple, but I don't know what...

Tom M
12-28-2005, 02:45 PM
I'm getting no love on this...the module isn't even showing up. I have vb3.5 and vbacmps 2.0. The module is set to active, but it just doesn't appear. I'm sure I'm overlooking something simple, but I don't know what...I know it's an obvious question but did you make sure it was checked to show on the page which you're expecting to see it? I know I've had that happen to me on occasion. Also, what's the url of the feed and I'll be happy to check it out as well.

euangel
12-28-2005, 06:29 PM
Thanks...that was the problem. Now I'm getting this error:

Warning: file_put_contents(/home/broncosfreak.com/rsscache/feeds.feedburner.com-orangeandblue.cache) [function.file-put-contents]: failed to open stream: No such file or directory in \modules\rss_cmps2.php on line 158

I assume I either have the wrong path or that directory isn't world writeable...waiting to hear back from my host on the issue...

euangel
12-28-2005, 11:56 PM
Okay...I got the above to work...now I'm trying to add another stream and getting the get_contents error:


Warning: file_get_contents( http://sports.yahoo.com/nfl/teams/den/rss.xml) [function.file-get-contents]: failed to open stream: Invalid argument in \modules\rss_cmps2.php on line 157

I think the feed is valid as both my feed reader and my browser have no trouble with it...

euangel
12-29-2005, 12:09 AM
Oops...had a couple of spaces in front of the feed...

Tom M
12-29-2005, 12:33 AM
I think the feed is valid as both my feed reader and my browser have no trouble with it...I know what's wrong, just not why it's happening. It'll take a bit for me to track it down.

euangel
12-29-2005, 12:46 AM
Okay, so here's the starnge thing...I can't get two feeds to work.

I had a module working in the center column (feed A) using this feed: http://feeds.feedburner.com/orangeandblue. Then, I copied that module, gave it a new name, designated it for the right column, and entered the Yahoo feed above (feed b).

Once I do that, the feed A module disappears, but feed b appears in the right column but still using the feed from feed A. Feed A is still shown as active in the ACP, but it doesn't appear on the home page. If I delete feed B, then it disappears, but Feed A still doesn't appear.

Did you follow that?

Tom M
12-29-2005, 12:55 AM
My head hurts from reading that ;)

EDIT: deleted patch as file has been updated in first post.

euangel
12-29-2005, 02:57 AM
If you think it's something you'll have sorted soon, I'll just wait for the update, because I haven't rolled out this feature publicly yet anyway.

Tom M
12-29-2005, 03:06 AM
New files (rssfeed.module and rss_cmps2.php) have been uploaded to the first post.

12/28/2005
1. Fixed a bug when the closing </image> tag had other tags following it.

To update replace the rss_cmps2.php file or uninstall and reinstall the module.

euangel
12-29-2005, 03:20 AM
I'll try this one...thanks.

FYI, your sample code in the original post which shows how to include the date has an extra ')' at the end of the first line of code.

Tom M
12-29-2005, 03:27 AM
FYI, your sample code in the original post which shows how to include the date has an extra ')' at the end of the first line of code.
Thanks - it's fixed now.

euangel
12-29-2005, 03:29 AM
That's working, though it was still a little cranky. I had to re-enter the URL of the feed in the first module for some reason, because both modules ended up showing the same feed. I'm going to try a third feed...we'll see how that goes!

How hard would it be for a non-coder like me to have the feeds only show the headlines and date, with none of the actual article content?

euangel
12-29-2005, 03:54 AM
Okay...it didn't like three feeds. Two are working, but I wasn't able to add the third...

euangel
12-29-2005, 05:41 AM
D'oh. I had two working, but I tried to change the feed on the second one and broke the whole thing. :(

Tom M
12-29-2005, 11:16 AM
D'oh. I had two working, but I tried to change the feed on the second one and broke the whole thing. :(How did you create the multiple feeds? I've got 4 different feeds running correctly on my test page.

I've run across a problem in CMPS when duplicating modules that causes things to "break" with the only way to resolve it to delete all the custom modules that experience a problem, including the original one, and starting the process over. I've also had to go into the db and manually delete records. I thought this was only related to when creating the module and options but apparently not. I've reported it and similar behavior as a problem.

What I do now that seems to work is to import the module and leave it alone. I then make a copy of it and save it. Then I go back and edit that copy and leave the blank one alone. If you need a 2nd module repeat the copy process, making for a total of 3 versions (the original plus 2 copies). I currently have 5 copies of the RSS module, 4 of which are "real" and 1 is the original blank one.

GrrrlRomeo
12-29-2005, 12:21 PM
How do I prevent catagory from appearing? I think it's category anyway. I'm using a Google feed and apparently category is the same as the title and author so it's kind of redundant. I made changes to the rssbits template and it doesn't seem to be sticking...or I'm trying to change it in the wrong place.

My site is here: http://indigovortex.com

GrrrlRomeo
12-29-2005, 01:11 PM
Nevermind, I got it. It was Google. I thought I could skip using Grouper since Google has rss news feeds, however Google adds html to their rss feed as well as repeating the title in the item description.

Tom M
12-29-2005, 01:54 PM
If the HTML is consistent it's possible to use the Data Modification code section for the feed to strip it out (unless the feed TOS says you can't do this). This removes the category$rss_item['CATEGORY'] = '';w/o having to esdit the adv_portal_rssbits template.

This shortens long descriptions and adds a '... [Read More]' that will open in a new windowsubstr($rss_item['DESCRIPTION'], 0, strrpos(substr($rss_item['DESCRIPTION'], 0, 200), ' ')) . '... [<a href="' . $rss_item['LINK'] . '" target="_blank">Read More]';
The possibilities are pretty endless as to what you can do w/o having to edit the templates.

euangel
12-29-2005, 02:03 PM
Thanks Tom...I'll give that a try. Does deleting the module remove the info in the database, or am I going to need to go it to the database to do that?

I'm also considering showing a full entry rather than just the description. What would the code be for that?