TinyPortal

Development => Support => Topic started by: VladTepes on March 24, 2017, 05:29:32 AM

Title: RSS feed block question
Post by: VladTepes on March 24, 2017, 05:29:32 AM
I did a search but there was nothing newer than 2009, and even then very little.

I haven't installed TP yet (will be doing so in the not distant future) but from the documents site it tells me there is an RSS feed block?

If so that's brilliant - assuming it works.

1. Does it work?
2. Is it a stand-alone solution or does an RSS reader of some sort need to be installed as well?

I do hope I can get RSS up and running as I'd like a number of motorsport feeds in different boards on my site. My members would love it :)
Title: Re: RSS feed block question
Post by: lurkalot on March 24, 2017, 07:07:10 AM
There is a built in RSS feed block, but I'll be honest and say, although it works it offers very little in the way of control, or display options. In my opinion you'd be better off finding a different RSS script on the web, and running that in a block, or article. 

The RSS feature is something that has bugged me for quite some time. tbh.
Title: Re: RSS feed block question
Post by: illori on March 24, 2017, 09:11:44 AM
http://www.tinyportal.net/index.php?topic=35742.msg288389#msg288389 might be useful.
Title: Re: RSS feed block question
Post by: lurkalot on March 24, 2017, 07:03:20 PM
Quote from: illori on March 24, 2017, 09:11:44 AM
http://www.tinyportal.net/index.php?topic=35742.msg288389#msg288389 might be useful.

Thanks illori, I forgot about that.  :-[ Would it be an idea to incorporate that into the next release of TP1.x, if there is one?
Title: Re: RSS feed block question
Post by: illori on March 24, 2017, 09:34:15 PM
i hope we can once we complete the beta stuff.
Title: Re: RSS feed block question
Post by: lurkalot on March 25, 2017, 12:01:50 PM
Quote from: illori on March 24, 2017, 09:34:15 PM
i hope we can once we complete the beta stuff.

I was going to give your code edits a test in TP1.2R3 but it appears the code is different. 
Title: Re: RSS feed block question
Post by: VladTepes on March 28, 2017, 04:58:25 AM
Meanwhile I've looked and found several RSS feed scripts but have no idea how good they are, whether they will work etc.
Does anyone have a particular recommendation?
Title: Re: RSS feed block question
Post by: lurkalot on March 28, 2017, 07:42:58 AM
Quote from: VladTepes on March 28, 2017, 04:58:25 AM
Meanwhile I've looked and found several RSS feed scripts but have no idea how good they are, whether they will work etc.
Does anyone have a particular recommendation?

The script I mentioned in the other thread added a PHP block seems to work ok. Code, http://bavotasan.com/2010/display-rss-feed-with-php/

This is what it looks like atm. http://cctestsite.info/forums/index.php Added a feed from your forum so you can see what it looks like, and the original feed underneath from one of my forums. seems to handle images ok as well.
Title: Re: RSS feed block question
Post by: VladTepes on March 28, 2017, 01:03:54 PM
This forum needs a say thanks mod... so... thanks !  :)
Title: Re: RSS feed block question
Post by: VladTepes on March 28, 2017, 01:07:31 PM
Quote
The script I mentioned in the other thread added a PHP block seems to work ok. Code, http://bavotasan.com/2010/display-rss-feed-with-php/

Bugger that site is offline at the moment.
Title: Re: RSS feed block question
Post by: VladTepes on March 28, 2017, 02:23:26 PM
OK well I grabbed said script as follows:

$rss = new DOMDocument();
$rss->load('http://www.motogp.com/en/news/rss');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = 5;
for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
$link = $feed[$x]['link'];
$description = $feed[$x]['desc'];
$date = date('l F d, Y', strtotime($feed[$x]['date']));
echo '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
echo '<small><em>Posted on '.$date.'</em></small></p>';
echo '<p>'.$description.'</p>';
}


but the actual feed has some super-odd characters in it (see attached).
Any ideas on why / a fix for this?

Secondly, how do I mod that script so it grabs images too?

Thanks.
Title: Re: RSS feed block question
Post by: lurkalot on March 28, 2017, 09:03:13 PM
Might have to convert to UTF-8 to stop that from happening.  This will also give you a bit of future proofing, as The new SMF 2.1 is already UTF-8 as standard.

http://wiki.simplemachines.org/smf/UTF-8_Readme

Backup database etc before doing anything.

Actually my testsite was displaying that MotoGP feed same as yours, so I just converted it to UTF-8 all seems fine now.http://cctestsite.info/forums/index.php