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,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 728
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 562
  • Total: 562

Formatting RSS

Started by Freddy, January 12, 2007, 09:42:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Freddy

Hi, Anyone know an easy way to format an RSS feeds for use in a Tiny Portal block ?

My problem is that I have an RSS feed I want to use but it has too many lines.  There was an online tool to do this, so I could limit to say 5 entries, but I can't find it (seems to be down).  Hope someone can help before I have to learn another programming language!.. thanks.

G6Cad

http://www.tinyportal.net/index.php?topic=11431.msg94676#msg94676

parameters could be "rssfeed" "rssfeed in a bloc" or even look in the block code and snippets board.

Another board would be tpsupport and development  :)

Freddy

#2
Thanks G6 , much appreciated :) I'll try some more lookin'

alex777

Hi, is there anybody who could tell me how I can limite the lines of the rss feeds? Beneath you can see the code of my phpbox.


// An RSS Reader to grab news from whichever site you choose
$backend = "http://www.weltwoche.ch/rss/rss.xml"; //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);

G6Cad

The feeds are what they are, TP only generate the code the RSS feed is called from.
So more or less you have to ask the sourse from where you call the RSS from to change it for you.

A search in here will also give you some more info on some scripts you can use to convert the RSS feeds with some generator on the net. Cant remember the url now, but a search in here or google should lead you in the right direction.

alex777

Look at the code beneath:

<script language="JavaScript" src="http://feed2js.org//feed2js.php?src=http%3A%2F%2Fwww.weltwoche.ch%2Frss%2Frss.xml&amp;chan=y&amp;num=7&amp;desc=1&amp;utf=y" type="text/javascript"></script>

<noscript>
<a href="http://feed2js.org//feed2js.php?src=http%3A%2F%2Fwww.weltwoche.ch%2Frss%2Frss.xml&amp;chan=y&amp;num=7&amp;desc=1&amp;utf=y&amp;html=y">View RSS feed</a>
</noscript>


The feedsource is exactly the same but I was able to reduce the lines. But there is something else I don't like. So I really would like to use the code I have in the phpbox but with the same possibility to limite the lines as it is possible with the code in the scriptbox.

This website is proudly hosted on Crocweb Cloud Website Hosting.