Main Menu
collapse

Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

User Info

Welcome Guest.
Please log in.

Who's Online

  • Dot Guests: 1311
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]


NEED HELP? If you're looking for support with Simple Portal, look no further than the Support Board!

Display MediaWiki RSS Feed In Simple Portal Block

Started by newtoallthis, August 28, 2011, 10:27:28 AM

Previous topic - Next topic

0 Members and 7 Guests are viewing this topic.

newtoallthis

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.
SMF 2.0 Gold
SP 2.3.3

Divecall


Old Fossil

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.

[code]    global $rss_data, $rss_current, $rss_counter, $rss_main;

    // This needs to be unique to each block
    $id = 1;
   
    // Your feed url
    $feed = 'http://FEED URL';

    $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
Daily backups mean less headaches

Block Set Up

I may be no coding expert but I am willing to help where I can.

I eat Spammers for breakfast

[SiNaN]

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.
And slowly, you come to realize... It's all as it should be...

Old Fossil

Do ya need a guinea pig for testing the new version Sinan?
Daily backups mean less headaches

Block Set Up

I may be no coding expert but I am willing to help where I can.

I eat Spammers for breakfast

newtoallthis

Thanks for the code, Brack 1, I'll give a try and report back.

Looking forward to the 2.3.4! 
SMF 2.0 Gold
SP 2.3.3

newtoallthis

@ 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. 
SMF 2.0 Gold
SP 2.3.3

[SiNaN]

And slowly, you come to realize... It's all as it should be...

Old Fossil

Quote from: newtoallthis on August 29, 2011, 06:27:48 AM
@ 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.
Daily backups mean less headaches

Block Set Up

I may be no coding expert but I am willing to help where I can.

I eat Spammers for breakfast

newtoallthis

I'm not casting aspersions, just making you aware of the message.
SMF 2.0 Gold
SP 2.3.3

Old Fossil

Quote from: newtoallthis on August 29, 2011, 12:47:27 PM
I'm not casting aspersions, just making you aware of the message.

No worries bud. Seems as though a contact is required lol.
Daily backups mean less headaches

Block Set Up

I may be no coding expert but I am willing to help where I can.

I eat Spammers for breakfast

ccbtimewiz

Quote from: Brack1 on August 29, 2011, 09:50:13 AM
Quote from: newtoallthis on August 29, 2011, 06:27:48 AM
@ 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.

AngelinaBelle

Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

newtoallthis

Not got round to trying it yet, but it would be useful to know where to put it!  :nervous-happy:

SMF 2.0 Gold
SP 2.3.3

Old Fossil

Quote from: newtoallthis on August 30, 2011, 04:48:38 PM
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.
Daily backups mean less headaches

Block Set Up

I may be no coding expert but I am willing to help where I can.

I eat Spammers for breakfast

newtoallthis

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.
SMF 2.0 Gold
SP 2.3.3

Divecall


AngelinaBelle

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';
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

newtoallthis

Quote from: AngelinaBelle on September 01, 2011, 11:32:16 AM
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.
SMF 2.0 Gold
SP 2.3.3

AngelinaBelle

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.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?