TinyPortal

Development => Support => Topic started by: Freddy on January 12, 2007, 09:42:29 PM

Title: Formatting RSS
Post by: Freddy on January 12, 2007, 09:42:29 PM
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.
Title: Re: Formatting RSS
Post by: G6Cad on January 12, 2007, 10:31:47 PM
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  :)
Title: Re: Formatting RSS
Post by: Freddy on January 13, 2007, 01:32:01 PM
Thanks G6 , much appreciated :) I'll try some more lookin'
Title: Re: Formatting RSS
Post by: alex777 on January 23, 2008, 08:55:35 PM
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);
Title: Re: Formatting RSS
Post by: G6Cad on January 23, 2008, 10:20:37 PM
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.
Title: Re: Formatting RSS
Post by: alex777 on January 24, 2008, 01:48:39 AM
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.