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: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 346
  • Total: 346

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.

vanguard

Any way to tweak the code so the links will open a new window?

Zetan

Unfortunately.. and I may be wrong, but I think that it's set by the sites hosting the feed. I could be wrong and hope there is a way, because I like all external links to open in a new window without navigating away from my site.

IchBin

Quote from: Zetan on June 17, 2007, 09:18:58 AM
Unfortunately.. and I may be wrong, but I think that it's set by the sites hosting the feed. I could be wrong and hope there is a way, because I like all external links to open in a new window without navigating away from my site.
You are correct Zetan. The links are created by the RSS feed. If its not set to open in another windows theres not much you can do about it.


vanguard

Ok, one more q and I'll leave everyone alone :) :

I'm no PHP coder, so, I wonder if there is a way to have more than one rss feed render in the same article?

Going to try to find some PHP instruction soon. (Book/whatever.)


Thanks in advance!

IchBin

You'll have to use a 3rd party script to do this I think. TP doesn't have any such feature built in.

vanguard

Thanks Ich,

This thread featured this code that works great. I wondered if it could be modified slightly:

Quote from: nokonium on December 23, 2006, 12:28:36 PM
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>'; 




wilsy

Hi all,

I am using the following code which works really well: -

// TP RSS Article Script

// TP Function
$context['TPortal']['rss_notitles']= false;

// Create An XML Parser
$xml_parser = xml_parser_create();

// Set The Functions To Handle Opening & Closing Tags
xml_set_element_handler($xml_parser, "startElement", "endElement");

// Set The Function To Handle Blocks Of Character Data
xml_set_character_data_handler($xml_parser, "characterData");

// Open The XML File
$fp = fopen("http://feeds.feedburner.com/bbcnewsfrontpagefullfeed?format=xml","r")
or die("Error reading RSS data.");

// Read The XML File 4KB At A Time
while ($data = fread($fp, 4096))

// Parse Each 4KB Chunk With The XML Parser
xml_parse($xml_parser, $data, feof($fp))

// Handle errors in parsing
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 XML File
fclose($fp);

// Free Up Memory Used By XML Parser
xml_parser_free($xml_parser);


I would like to specify the number of items to be called from the feed. Is this possible?

Regards,

Wilsy.

IchBin

You have to use a third party script to capture your RSS feed and limit it or change it in any way. TinyPortal does not control the feed in such a way.

mrdr

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
Great site! I rather use js script for feeds then rss feed block because that speed up tp loading page.

This website is proudly hosted on Crocweb Cloud Website Hosting.