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

Recent

Welcome to TinyPortal. Please login or sign up.

February 10, 2025, 08:13:43 PM

Login with username, password and session length
Members
  • Total Members: 3,946
  • Latest: Sparo
Stats
  • Total Posts: 195,471
  • Total Topics: 21,258
  • Online today: 103
  • Online ever: 6,457 (November 30, 2024, 02:40:09 PM)
Users Online
  • Users: 0
  • Guests: 67
  • Total: 67

RSS feed in articles not blocks???

Started by Uber_Tiny, December 20, 2006, 06:23:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Gidget

Hi Lesmond

Not to worry  :)  I did some more research this afternoon and found this
http://magpierss.sourceforge.net/
which used in conjunction with a php article allows me to do just what I wanted  ;D

Cheers

Gidget

Nokonium

There is another way to put an rss feed into an article, one I've used for some time.

You will find the TP RSS parse code in TPortal.php, I make a copy of that in the TPortal.php file, one for each RSS feed to be parsed, I also remake these additions with each change to Bloc's TP RSS parsing.

This is for TP 0.97

Find in TPortal.php and copy it

function TPparseRSS()
{

global $context, $settings, $options, $scripturl, $txt, $modSettings;

$backend = $context['TPortal']['rss'];
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$curl = "";

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

$xml_parser = xml_parser_create();
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);
}


Rename the function and put the url in the $backend =

Here is one I have done for Secunia

// RSS feed from Secunia
function RSSsecunia()
{

global $context, $settings, $options, $scripturl, $txt, $modSettings;

Ã,  $backend =Ã,   'http://secunia.com/information_partner/anonymous/o.rss';
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$curl = "";

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

$xml_parser = xml_parser_create();
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);
}


In the php article (or php block) all you need is to call the function and set the style.

echo '<div style="padding: 5px;" class="smalltext">';
Ã,  Ã,  Ã,  Ã,   RSSsecunia();
Ã,  Ã,  Ã,  Ã,   echo '</div>';Ã, 



gerrymo

Quote from: G6 on December 20, 2006, 06:25:55 AM
Have you tried to convert the RSS to html script and then used the converted feed in to a script in an article ?

IF you have the RSS feed, you can go here and convert the feed to other code formats.
http://www.rss-to-javascript.com/p/138.html

Anyone know where I can get a script like this that I can run myself? IE: Input URL, and Output Javascript (ot similar). Nothing fancy, just convert it to a format that can easily be added to pages, and run from my server?

Uber_Tiny

I would check out SourceForge.net

They may help you out there.

Using your code lesmond I am now getting an error anytime someone looks at the RSS feed and the lettering in the feed it's self is messed up. Would anyone be able to help me out on how to fix that?



The error code I get.
8: Use of undefined constant r - assumed 'r'
File: /home/geforce3/public_html/forums/Themes/default/TPortal.template.php (eval?)
Line: 41

G6Cad

What language encoding do you use ? UTF8 or regular ?   
Mostly the RSS feeds are the ones that have the faults as they are simply fetched from other sites, but your encoding is most likly the error in this case

Uber_Tiny

Quote from: G6 on December 23, 2006, 07:43:11 PM
What language encoding do you use ? UTF8 or regular ?   
Mostly the RSS feeds are the ones that have the faults as they are simply fetched from other sites, but your encoding is most likly the error in this case
Regular

Thurnok

Your error is from the following line:

$fp = fopen($backend, r);


change it to:

$fp = fopen($backend, "r");


The error code you receive that is.. not your encoding display problem.

Uber_Tiny

Quote from: Thurnok on December 23, 2006, 07:50:00 PM
Your error is from the following line:

$fp = fopen($backend, r);


change it to:

$fp = fopen($backend, "r");


The error code you receive that is.. not your encoding display problem.
TY...that got rid of the error.

Shadow

Thanks les. I am using this code right now.

vanguard

#19
Works great thanks!!!

I'm using rss in articles instead of in blocks and attached to forum sections like I was doing before this.

:)