I am not an HTML wiz kid so I will ask here. Yes I have looked everywhere for others that may want this but found nothing in the search that has to do with my situation, so here goes.
I am using
SMF 1.1.1
TinyPortal v0.9.6beta
I was wondering if there is a way or if someone could help me out with the HTML on how to install an RSS feed into a article. I have tryd different ways but to no avail. Reason being is that I have it set up to where when I write a new article it places the link in the block I set up for it's category. I don't want to show the RSS feed on the main page as it takes up way to much space and they also tend to slow the site down being on the main page.
Any help would be greatly appreciated.
Oh and maybe a suggestion for feature TP setup to allow you to pick if you want an RSS feed when making an article.
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
That's a very cool site. And a great suggestion. Since you can use javascript in Articles, I think that will probably give you exactly what you need. Let us know how it turns out so others might do the same. :)
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
Thanks for that link. But it didn't seem to work. :(
This is the code I get from them.
<script language="JavaScript" src="http://convert.rss-to-javascript.com/?simple_chan=1&desc=1&src=http%3A%2F%2Fwww.nvidia.com%2Fobject%2Frss_nvidia_pressroom">
</script><noscript>Your browser does not support JavaScript. <a title='RSS-to-JavaScript.com: Free RSS to JavaScript Converter' href=http://www.rss-to-javascript.com/?p=151,381&simple_chan=1&desc=1&src=http%3A%2F%2Fwww.nvidia.com%2Fobject%2Frss_nvidia_pressroom&as_html=1>Click to read the latest news</a>.</noscript>
<a href=http://www.rss-to-javascript.com target=_blank title='RSS-to-JavaScript.com: Free RSS to JavaScript Converter'><img src=http://www.rss-to-javascript.com/images/rss-to-jss-small.gif alt='RSS to JavaScript' border=0></a>
Is there something I am missing that needs to be edited in that to make it work cause this is what it does on my site. LINK (http://www.geforce3d.net/forums/index.php?page=15)
heres one I use in a article (php)
Just change the feed to the one you want near the top of the code
// An RSS Reader to grab news from whichever site you choose
$backend = "http://rss.thisis.co.uk/ThisIsLeicestershire/LocalNews.rss"; //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);
Les has a good one.
There are a number of RSS feed blocks in the block code snippets area that look like they could work in an article, or modified to work in an article as well, even if they say they are for a center block or something.
But Les has a working one, that's probably your best bet to try out anyway.
Awesome Lesmond!! :up: :up:
That worked...thank you very very much!!
Lesmond Rocks!
Hi Lesmond
Thanks for the code :)
Is it possible to add something to the php article to format the output a bit differently?
I just want to have the titles in bold and a one line gap between each story, but I can't figure out how to do it (or if it is possible to do it).
Thanks in advance and Merry Christmas
Gidget
Gidget I cant help you with that, not much good with PHP, but I am a expert with copy and paste :)
And a Merry Christmas to you (https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.lesmonds.co.uk%2Fsmf%2FSmileys%2Fclassic%2Fsplat.gif&hash=deea9d290df32e71b4542e8bc282bba63d1cda54)
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
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>';Ã,Â
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?
I would check out SourceForge.net (http://sourceforge.net/search/?type_of_search=soft&words=rss+to+java)
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?
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.geforce3d.net%2Fuploder%2Falbums%2Fuserpics%2F10001%2Ferror.jpg&hash=d10de71d8bfe4c5ab2955e66e2d78f26bdb36aaa)
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
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
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
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.
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.
Thanks les. I am using this code right now.
Works great thanks!!!
I'm using rss in articles instead of in blocks and attached to forum sections like I was doing before this.
:)
Any way to tweak the code so the links will open a new window?
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.
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.
Thanks guys
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!
You'll have to use a 3rd party script to do this I think. TP doesn't have any such feature built in.
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>';
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.
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.
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.
I tried Lesmond's and it worked GREAT! Thanks a lot!
This works great! http://itde.vccs.edu/rss2js/build.php.
Limit the number of items and open in new windows. Simply paste the RSS feed, select some options and click Generate Javascript. It takes less than a minute and you copy-and-paste about 12 lines of code into your article. It even has a style tool.
Brilliant!! :up:
I tried this in a script box and it works great.
he only problem was the when I tried their stylesheet option it didn't close the <A tag and the whole page was a link to the RSS Feed. So I couldn't edit it!