SimplePortal
Support => English Support => Topic started by: newtoallthis on August 28, 2011, 10:27:28 AM
-
I'm trying to create a custom block (RSS) in Simple Portal to display my MediaWiki RSS feed of 'Recent Changes'.
I've added /index.php?title=Special:Recentchanges&feed=rss to the MediaWiki URL but on previewing the new block I get the error 'XML error: Undeclared entity warning at line 150'.
Any help advice would be welcome.
-
I was looking for something similar, too - some month ago...
It is not possible...
http://simpleportal.net/index.php?topic=7615.msg42675#msg42675
-
The following is some code another portal user (name not remembered) left on a topic.
This is my rss which I use for local news.
Hope it helps.
You can see it working on my forum at www.miltonkeynesaware.co.cc the block has been renamed as Local News.
global $rss_data, $rss_current, $rss_counter, $rss_main;
// This needs to be unique to each block
$id = 1;
// Your feed url
$feed = 'http://[color=red]FEED URL';[/color]
$rss_data = array();
$rss_current = "";
$rss_counter = 0;
$rss_main = '';
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "sp_startElement", "sp_endElement");
xml_set_character_data_handler($xml_parser, "sp_characterData");
if (!($fp = @fopen($feed, "r")))
{
echo 'Invalid feed URL.';
return;
}
while ($data = fread($fp, 4096))
{
if (!xml_parse($xml_parser, $data, feof($fp)))
{
$xmlerr = (sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
break;
}
}
fclose($fp);
xml_parser_free($xml_parser);
if (!empty($xmlerr))
{
echo $xmlerr;
return;
}
if (empty($rss_data))
{
echo 'No items to show.';
return;
}
if (isset($rss_data['ITEMS']))
{
echo '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
function toggleDescription(id)
{
id = \'rss_descr_\' + id;
if(document.getElementById(id).style.display == \'none\')
document.getElementById(id).style.display = \'\';
else
document.getElementById(id).style.display = \'none\';
}
// ]]></script>';
$max = count($rss_data['ITEMS']);
if ($max > 0)
{
for($i = 0; $i < $max; $i++)
{
echo '
<span style="font-weight: bold;" class="smalltext"><a href="javascript:toggleDescription(\'', $id, '_', $i, '\')">', $rss_data['ITEMS'][$i]['TITLE'], '</a></span><br />';
echo '
<div id="rss_descr_', $id, '_', $i, '" class="smalltext">
', html_entity_decode($rss_data['ITEMS'][$i]['DESCRIPTION']) . '<br /><br />
<a href="', $rss_data['ITEMS'][$i]['LINK'], '" target="_blank"><b>view link ยป</b></a>';
if ($i != $max - 1)
echo '<hr />';
echo '
</div>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
toggleDescription(\'', $id, '_', $i, '\');
// ]]></script>';
}
}
}
-
I just tried the feed from Wikipedia with the new RSS block I coded for 2.3.4 and it worked just fine. Hopefully the new block is going to solve most the issues people have with feeds.
-
Do ya need a guinea pig for testing the new version Sinan?
-
Thanks for the code, Brack 1, I'll give a try and report back.
Looking forward to the 2.3.4!
-
@ Brack1
This is what I get when I try to access your site.
ESET NOD32 Antivirus - Alert
Access denied !
Details:
Web page:
http://www.miltonkeynesaware.co.cc/
Description:
Access to the web page was blocked by ESET NOD32 Antivirus.
The web page is on the list of websites with potentially dangerous content.
Thought you ought to know.
-
Do ya need a guinea pig for testing the new version Sinan?
Nope, not yet.
-
@ Brack1
This is what I get when I try to access your site.
ESET NOD32 Antivirus - Alert
Access denied !
I'd move to a more reliable anti virus if I were you.
Nobody else has ever had the same message as you.
In fact the forum is almost 18 months old and has over 300 followers on twitter.
-
I'm not casting aspersions, just making you aware of the message.
-
I'm not casting aspersions, just making you aware of the message.
No worries bud. Seems as though a contact is required lol.
-
@ Brack1
This is what I get when I try to access your site.
ESET NOD32 Antivirus - Alert
Access denied !
I'd move to a more reliable anti virus if I were you.
ESET NOD32 is probably the most reliable anti-virus on the market. One of the best.
-
newtoallthis,
Did the code from Brack1 help?
-
Not got round to trying it yet, but it would be useful to know where to put it! :nervous-happy:
-
Not got round to trying it yet, but it would be useful to know where to put it! :nervous-happy:
Ops.
The php block is the one ya want.
-
OK, understood.
Placing this code in a PHP custom block and adding a rss feed URL (e.g. BBC) doesn't work.
Thanks for trying though.
-
Doesnt work for me, too (the block-code)....
-
hmm. In what way does it not work?
Even when you replace
// Your feed url
$feed = 'http://[color=red]FEED URL';[/color]
with something like
// Your feed url
$feed = 'http://simpleportal.net/index.php?type=rss;action=.xml';
-
hmm. In what way does it not work?
Even when you replace
// Your feed url
$feed = 'http://[color=red]FEED URL';[/color]
with something like
// Your feed url
$feed = 'http://simpleportal.net/index.php?type=rss;action=.xml';
I've tried various rss feeds and only one worked and even then not well.
xml is the bit that makes the difference it seems, but I can't trace paths to appropriate xml files for 99% of rss feeds.
-
I'm sorry to hear that brack1's RSS block is not working well for you.
I know that Sinan has been working on the RSS block for SimplePortal. In the past, it has used certain SMF functions that seemed as though they ought to do the job but did not quite do it. In the future, it will use functions that can handle valid RSS feeds.