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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,990
  • Total Topics: 21,323
  • Online today: 633
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 297
  • Total: 298
  • illori

RSS Feed Block - BUT, using PHP

Started by makphisto, January 09, 2007, 10:44:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Lesmond

Try this in a PHP block,
// An RSS Reader to grab news from whichever site you choose
$backend = "http://www.gijoefirefight.com/faq/feed/topten/rss.php"; //change this to match the rss feed url you wish to display.
// end


function endtheElement($parser, $tagName) {
// This function is used when an end-tag is encountered.
global $insideitem, $tag, $title, $description, $link;
 
  if ($tagName == "ITEM") {
    echo '<table width="100%" border="0"><tr>
      <td class="main-table">
      <span class="nav-head"><strong>
      ';
    printf("<p><b><a href='%s'>%s</a></b></p>", // make our title into an actual link
    trim($link),htmlspecialchars(trim($title))); // remove html characters from the title
 
    echo "</tr>";
    echo '<tr>
      <td class="nav">';
    printf("<p>%s</p>",$description); // Print out the live journal entry
    echo"</td>";
    echo "</tr>";
    echo "</table>";
    echo "<br>";
    $title = $description = $link = $insideitem = false;
   }
}

// Now to the parsing itself. Starts by creating it:

$xml_parser = xml_parser_create();

// Then setup the handlers:

xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");

// Open the actual datafile:

$fp = fopen($backend, r);

// Run through it line by line and parse:

while ($data = fread($fp, 4096)) {
  xml_parse($xml_parser, $data, feof($fp))
    or die(sprintf("XML error: %s at line %d",
           xml_error_string(xml_get_error_code($xml_parser)),
           xml_get_current_line_number($xml_parser)));
}

// Close the datafile

fclose($fp);

// Free any memmory used

xml_parser_free($xml_parser);

makphisto

I tried that feed on another TP/SMF site of mine (with a different domain) and it doesn't work.

I tried your code, and it doesn't work - still a blank box.

Just out of curiousity, I tried this in a scriptbox (I've seen it work elsewhere):

<script language="JavaScript" src="http://www.gijoefirefight.com/faq/feed/topten/rss.php" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
for (count = 0; count < numHeadlines; count++) {
   document.write('<a href="' + link[count] + '" target=_blank>' + headline[count] + '</a><br>');
}
</script>


It didn't work.  I have a crappy host, I wonder if that's the problem.

Ahh well.  Thanks again.

makphisto

Gah, this is driving me nuts. Anyone else want to take a stab at it?

knat

#13
I use this RSS ticker on my site.. i try put in your feed and it worked fine.. so check it out.. it might be the solution you are looking for  ;)

http://www.dynamicdrive.com/dynamicindex17/rsstickerajax/index.htm

If you want to see a demo look here: http://www.gapeindex.dk/index.php?www;page=29 (no hardcore content on that page)

Mine only shows the title but it can also show date and description..

I use mine in an article but i am sure you can use it in a block also.

Good luck with it  ;)

TWD

I'm just starting to play around with RSS feeds and am trying to put one in a right-side block.  I have no idea what exactly I'm supposed to do, but I thought I just needed to give it the URL of the feed, which is this case is http://furmanpaladins.cstv.com/event-toolbar-rss.xml

Comes up blank.  I assume I'm doing something incredibly naive, because I really don't understand RSS.  Little help?

rider

You can try this.Admin>TP>block manager.Create a new block and choose the rss feed one.
You can try this link for rss feeds.
http://www.2rss.com/cat2_31.html

Just add the link in the block and call it whatever you want.
I have it set up on my site as just front page blocks.Click on my sig and see if thats what you're after.Hope this helps. :)

jdvarner

I must be doing something wrong. Everytime i do a feed box and put the feed url its just an empty box?

rider

Quote from: jdvarner on February 18, 2007, 05:24:51 AM
I must be doing something wrong. Everytime i do a feed box and put the feed url its just an empty box?
How is it set up?Do you have show titles only checked?Maybe that has something todo with it.try this.create a rss feed block and use this feed to see if it works.Its one from my site so I know it works.
http://sports.espn.go.com/espn/rss/news

knat

sometimes you have to put in www or the feed wont work in the reader.. even thoug it works fine in a browser some readers wants the www.. try that  ;)

jdvarner

I tried exactly what rider has a few posts up:

You can try this.Admin>TP>block manager.Create a new block and choose the rss feed one.
You can try this link for rss feeds.
http://www.2rss.com/cat2_31.html

It shows empty. im running tp 0.9.7 with smf1.1.1

This website is proudly hosted on Crocweb Cloud Website Hosting.