php forum
php mysql forum
php mysql smarty
 
Page 1 of 2 1 2 >
Topic Options
#316765 - 02/28/08 02:29 PM Custom island that shows an rss feed
blaaskaak Offline
Member

Registered: 02/25/07
Posts: 286
Loc: The Netherlands

   Custom island that shows an rss feed to Del.icio.us Add to del.icio.us
  Digg Custom island that shows an rss feed Digg it
A quick and dirty one, it shows the content of an rss feed. I had one feed it didn't work with, and a few others it did work with. It just shows the headers+the link to the article.

Code:
/* PHP CODE HERE */
$display="";
$count=0;
$xml = getFeed('http://www.fotogalerijen.be/parkcast/parkcast.xml');
foreach( $xml as $feed ) {
if ($count>=10) {
break;
}
if( ! $feed['title'] ) {
break;
}
$display.="<a href=\"".$feed['link']."\">".$feed['title']."</a><br />";
$count++;
}

/* BODY HERE */
$body = <<<EOF
$display
EOF;


Just copy/paste above code in a custom field, set the caching time on some value, edit the hardcoded feed url, and edit the max number of entries (10 now).
_________________________

Top
#316766 - 02/28/08 02:57 PM Re: Custom island that shows an rss feed [Re: blaaskaak]
GEN Offline
Power User

Registered: 01/01/07
Posts: 51
Loc: UK
Works great, just wish it would open the links in a new window.

smile
_________________________
GEN
Give Yourself to the Dark Side @ http://www.galacticempire.net
Give Yourself to the Geek Side @ http://www.movingimagetoys.com
"Anakin, duck!"
"What's a duck?"

Top
#316767 - 02/28/08 04:05 PM Re: Custom island that shows an rss feed [Re: GEN]
blaaskaak Offline
Member

Registered: 02/25/07
Posts: 286
Loc: The Netherlands
Just add a target to the link. No rocket science needed to add that smile
_________________________

Top
#316771 - 02/28/08 08:23 PM Re: Custom island that shows an rss feed [Re: blaaskaak]
GEN Offline
Power User

Registered: 01/01/07
Posts: 51
Loc: UK
laugh
_________________________
GEN
Give Yourself to the Dark Side @ http://www.galacticempire.net
Give Yourself to the Geek Side @ http://www.movingimagetoys.com
"Anakin, duck!"
"What's a duck?"

Top
#316774 - 02/29/08 02:48 AM Re: Custom island that shows an rss feed [Re: GEN]
blaaskaak Offline
Member

Registered: 02/25/07
Posts: 286
Loc: The Netherlands
okay, I wanted a date/time added to it, so I took it a little further. Configuration is a bit more easy now since it's all listed on top. It also shows the content now of the feed if you fly over it.

Styles used are those from the buildin posts island.

enjoy!

Code:
// configuration
$feedurl = 'http://www.fotogalerijen.be/parkcast/parkcast.xml';
$maxentries = 10;
$showdate = 1;

// start code

$body = "";
$count = 0;
$dateinfo = "";
$xml = getFeed($feedurl);
foreach( $xml as $feed ) {
if ($count >= $maxentries) {
break;
}
if( !$feed['title'] ) {
break;
}
$link=$feed['link'];
$time=$feed['time'];
$title=$feed['title'];
$description=$feed['description'];
$pubdate=strtotime($feed['pubdate']);
$pubtime = $html->convert_time($pubdate);

if ($showdate)
$dateinfo = <<<EOF
<span class="small">
$pubtime
</span>
EOF;

$body.= <<<EOF
<tr>
<td class="{$style_side}alt-1" align="left">
<div title="$description">
<a href="$link" target="_blank">$title</a></div>
$dateinfo
</td>
</tr>
EOF;
$count++;
}


I just thought of some security issues if the feed would contain html, so just add feeds you trust ok wink I'm away for the weekend, so don't have time to get into it now.
_________________________

Top
#316777 - 02/29/08 06:48 PM Re: Custom island that shows an rss feed [Re: blaaskaak]
GEN Offline
Power User

Registered: 01/01/07
Posts: 51
Loc: UK
Perfect.

smile
_________________________
GEN
Give Yourself to the Dark Side @ http://www.galacticempire.net
Give Yourself to the Geek Side @ http://www.movingimagetoys.com
"Anakin, duck!"
"What's a duck?"

Top
#316837 - 04/05/08 08:07 PM Re: Custom island that shows an rss feed [Re: GEN]
GEN Offline
Power User

Registered: 01/01/07
Posts: 51
Loc: UK
A weird thing happens when I have two separate islands with the same code in on the same page but with two different urls to feeds.

It only shows one of the feeds in bot islands.

Hmmm
_________________________
GEN
Give Yourself to the Dark Side @ http://www.galacticempire.net
Give Yourself to the Geek Side @ http://www.movingimagetoys.com
"Anakin, duck!"
"What's a duck?"

Top
#316838 - 04/05/08 10:27 PM Re: Custom island that shows an rss feed [Re: GEN]
blaaskaak Offline
Member

Registered: 02/25/07
Posts: 286
Loc: The Netherlands
Hmm, I'll give that a try. Have you tried both url's seperate?
_________________________

Top
#316839 - 04/05/08 11:20 PM Re: Custom island that shows an rss feed [Re: blaaskaak]
GEN Offline
Power User

Registered: 01/01/07
Posts: 51
Loc: UK
Well, when I have only one instance of the code in an island and one URL it shows the feed

But if I have the same code in two islands, even with separate urls only one feed shows up in both islands even though the urls to the feeds are different

I'm using a different code at the minute but I really like the above code, just can't understand why it only seems to work in one instance
_________________________
GEN
Give Yourself to the Dark Side @ http://www.galacticempire.net
Give Yourself to the Geek Side @ http://www.movingimagetoys.com
"Anakin, duck!"
"What's a duck?"

Top
#316852 - 04/08/08 04:49 PM Re: Custom island that shows an rss feed [Re: GEN]
AllenAyres Administrator Offline
I type Like navaho

Registered: 03/10/00
Posts: 25411
Loc: Texas
Very nice Yarp! How difficult would it be to include a pit of the post body, similar to how active topics does it, but only for the specified forum(s)?
_________________________
- Allen wavey
- What Drives You?

Top
#316857 - 04/09/08 03:19 PM Re: Custom island that shows an rss feed [Re: AllenAyres]
blaaskaak Offline
Member

Registered: 02/25/07
Posts: 286
Loc: The Netherlands
Wouldn't be difficult at all. If it's a field in the feed, you can display it.

I do know I played with a version during dev that had the message content as tooltip text.
_________________________

Top
#316886 - 04/25/08 06:36 AM Re: Custom island that shows an rss feed [Re: blaaskaak]
Myke Offline
Power User

Registered: 09/06/99
Posts: 87
Loc: Sydney, Australia
Thanks for this! I was previously using an external rss reader (lastRSS) in order to populate a custom island, but this is much cleaner! I'm using it to show a list of recent changes from our wiki (http://virtuafighter.com/ bottom left island).

I feel a bit silly asking this, because my searching hasn't been successful, but where can I find some documentation on getFeed() ? Specifically, I'd like to know what rss protocols it supports, and what fields it returns (or does that just depend on the rss feed?)

Top
#316887 - 04/25/08 06:55 AM Re: Custom island that shows an rss feed [Re: Myke]
blaaskaak Offline
Member

Registered: 02/25/07
Posts: 286
Loc: The Netherlands
getfeed is a function that is in the ubb sourcecode, but as far as I know, it is not used anywhere by ubb itself. I found about it by trying out Ian Spence' rss topic creator.

it's in /libs/ubbthreads.inc.php if you want to have a look at it.
_________________________

Top
#316888 - 04/25/08 07:36 AM Re: Custom island that shows an rss feed [Re: blaaskaak]
Gizmo Administrator Online   shocked
Wizard

Registered: 01/10/00
Posts: 5119
Loc: Portland, OR, USA
Initially I believe it was used to parse an RSS feed from ubbcentral; but went wonky on some sites...
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design Owner

Top
#316889 - 04/25/08 10:23 AM Re: Custom island that shows an rss feed [Re: Gizmo]
blaaskaak Offline
Member

Registered: 02/25/07
Posts: 286
Loc: The Netherlands
Ah, the latest new thingy in control panel, yep, that would be it laugh
_________________________

Top
#316894 - 04/29/08 03:17 PM Re: Custom island that shows an rss feed [Re: blaaskaak]
Jaymo Offline
Lurker

Registered: 04/29/08
Posts: 7
Hey, blaaskaak, this is a cool tool - I'm using it successfully but am experiencing the same issue mentioned above, where, despite using three unique URL's, each Island displays information identical to the content of the first Custom Island.

Any insight would be much appreciated!

Let me show you the three pieces of code I'm using:

This one displays the headlines from Variety.com:

Code:
/* PHP CODE HERE, IF NECESSARY */

$display="";
$count=0;
$xml = getFeed('http://feeds.feedburner.com/variety/news/film');
foreach( $xml as $feed ) {
if ($count>=5) {
break;
}
if( ! $feed['title'] ) {
break;
}
$display.="<a href=\"".$feed['link']."\">".$feed['title']."</a><br /><br />";
$count++;
}

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF
$display
EOF;
/* DO NOT CHANGE THE LINE ABOVE */


The following two, though possessing unique URL's, display the same info as the code listed above.

Code:
/* PHP CODE HERE, IF NECESSARY */

$display="";
$count=0;
$xml = getFeed('http://feeds.feedburner.com/variety/reviews/film');
foreach( $xml as $feed ) {
if ($count>=5) {
break;
}
if( ! $feed['title'] ) {
break;
}
$display.="<a href=\"".$feed['link']."\">".$feed['title']."</a><br />";
$count++;
}

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF
$display
EOF;
/* DO NOT CHANGE THE LINE ABOVE */

/* PHP CODE HERE, IF NECESSARY */

$display="";
$count=0;
$xml = getFeed('http://link.brightcove.com/services/link/bcpid714034225?action=rss');
foreach( $xml as $feed ) {
if ($count>=5) {
break;
}
if( ! $feed['title'] ) {
break;
}
$display.="<a href=\"".$feed['link']."\">".$feed['title']."</a><br />";
$count++;
}

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF
$display
EOF;
/* DO NOT CHANGE THE LINE ABOVE */



Top
#316895 - 04/30/08 12:53 AM Re: Custom island that shows an rss feed [Re: Jaymo]
Ian_W Global Moderator Offline
Veteran

Registered: 02/22/02
Posts: 2570
Loc: England
Just a thought - try adding 1, 2 & 3 after each $feed, $xml, $display etc. for each feed, so that the code is unique.

I have not tried this, but it is worth a try smile
_________________________
Fans Focus - Focusing on Fans of Sport

(Okay - mainly football (the British variety wink at the moment - but expanding all the time....)

Top
#316899 - 04/30/08 02:18 PM Re: Custom island that shows an rss feed [Re: Ian_W]
Jaymo Offline
Lurker

Registered: 04/29/08
Posts: 7
ARRG! Sounded like a great idea, Ian, but nope, same result....

Top
#316905 - 05/01/08 01:25 PM Re: Custom island that shows an rss feed [Re: Jaymo]
blaaskaak Offline
Member

Registered: 02/25/07
Posts: 286
Loc: The Netherlands
Did a couple of tries to get multiple feeds running, but no luck so far yet frown
_________________________

Top
#316907 - 05/01/08 07:14 PM Re: Custom island that shows an rss feed [Re: blaaskaak]
arentzen Offline
Newbie

Registered: 10/05/06
Posts: 19
Loc: Denmark
Hello out there. Its been a long time ago since last visit.... But i'd installed version 7.2.2 and has also struggeled with feeds in custom boxes. If you running PHP5, there is a function called simplexml_load_file which works excellent.

The code generates a link, a date, and a short description with 45 chars. Replace the url to the wanted feed in $feed


Php Code:
/* PHP CODE HERE, IF NECESSARY */
$feed = simplexml_load_file("http://www.dr.dk/nyheder/service/feeds/allenyheder");
$taeller  = 0;
$antal = 5; /*number of news*/
foreach($feed->channel->item as $item){
while($taeller<$antal){

/* formatting description with 45 chars*/
if (strlen($item->description) > 45) {
$item->description  = substr($item->description , 0, 45);
}
/* formatting date*/
$pubdate=strtotime($item->pubDate);
$pubtime = $html->convert_time($pubdate);
$dateinfo = <<<EOF
<span class="small">
$pubtime
</span>
EOF;

$link = utf8_decode("<a href='{$item->link}' target='_blank'>{$item->title}</a><br />");
$description= utf8_decode("{$item->description}...<br />");


$body.= <<<EOF

<tr>
<td class="{$style_side}alt-1" align="left">$link
$dateinfo <br />
$description
</td>
</tr>
EOF;

break;

}
$taeller ++;

}

/* DO NOT CHANGE THE LINE BELOW */  

_________________________
Peter Arentzen
trosfrihed.dk

Top
Page 1 of 2 1 2 >


Moderator:  sirdude 
Top Posters Last 30 Days
AllenAyres 12
Gizmo 10
S7ARBVCK 2
Cambridge 1
Murphdog 1
MattUK 1
Kevin H 1
Who's Online
0 Registered (), 39 Guests and 9 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Latest Posts
BeyondCompare v3.00
by blaaskaak
09/05/08 02:46 PM
Noob - need help, or a reality check!
by Gizmo
09/04/08 03:21 AM
Here I am! Rock me like a Hurricane!
by AllenAyres
09/02/08 03:05 PM
[7.x] Generic Page Outside of forum directory
by Gizmo
08/30/08 05:43 PM
Team UBBDev Rides Again!
by Gizmo
08/28/08 11:45 PM
Multiple Identity Detector
by MattUK
08/28/08 04:10 PM
[7.3.x] ubb.links
by AllenAyres
08/26/08 09:57 AM
New Mods
Installing FlashChat with 7.3
by Paug
08/23/08 12:14 AM
[7.3.x] ubb.links
by AllenAyres
06/20/08 11:50 PM
[7.2.1] - Naked shoutbox
by sirdude
08/17/07 10:36 PM
[7.x] Generic Page Outside of forum directory
by
01/14/07 10:58 PM
Multiple Identity Detector
by
12/30/06 06:39 PM
Newest Members
veedubb8, twentyseven, Claus1, welcomeback1, Paug
13327 Registered Users

 

 

 
fusionbb message board php hacks