TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 10:58:32 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,106
  • Total Topics: 21,213
  • Online today: 358
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online

RSS feed block question

Started by VladTepes, March 24, 2017, 05:29:32 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

VladTepes

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 :)

lurkalot

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.


lurkalot

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?

illori

i hope we can once we complete the beta stuff.

lurkalot

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. 

VladTepes

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?

lurkalot

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.

VladTepes

This forum needs a say thanks mod... so... thanks !  :)

VladTepes

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.

VladTepes

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.

lurkalot

#11
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