SimplePortal

Support => English Support => Topic started by: newtoallthis on August 28, 2011, 10:27:28 AM

Title: Display MediaWiki RSS Feed In Simple Portal Block
Post 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.
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: Divecall on August 28, 2011, 11:03:22 AM
I was looking for something similar, too - some month ago...

It is not possible...

http://simpleportal.net/index.php?topic=7615.msg42675#msg42675
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: Old Fossil on August 28, 2011, 11:46:54 AM
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: [Select]
    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>';
               
            }
        }
    }
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: [SiNaN] on August 28, 2011, 12:09:29 PM
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.
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: Old Fossil on August 28, 2011, 01:21:48 PM
Do ya need a guinea pig for testing the new version Sinan?
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: newtoallthis on August 29, 2011, 05:04:39 AM
Thanks for the code, Brack 1, I'll give a try and report back.

Looking forward to the 2.3.4! 
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: 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 !

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. 
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: [SiNaN] on August 29, 2011, 09:27:06 AM
Do ya need a guinea pig for testing the new version Sinan?

Nope, not yet.
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: Old Fossil on August 29, 2011, 09:50:13 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.
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: newtoallthis on August 29, 2011, 12:47:27 PM
I'm not casting aspersions, just making you aware of the message.
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: Old Fossil on August 29, 2011, 01:07:17 PM
I'm not casting aspersions, just making you aware of the message.

No worries bud. Seems as though a contact is required lol.
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: ccbtimewiz on August 29, 2011, 04:28:49 PM
@ 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.
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: AngelinaBelle on August 30, 2011, 09:29:05 AM
newtoallthis,
Did the code from Brack1 help?
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: 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:

Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: Old Fossil on August 30, 2011, 06:00:48 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.
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: newtoallthis on August 31, 2011, 03:29:36 PM
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.
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: Divecall on August 31, 2011, 06:02:46 PM
Doesnt work for me, too (the block-code)....
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: AngelinaBelle on September 01, 2011, 11:32:16 AM
hmm.  In what way does it not work?
Even when you replace
Code: [Select]
    // Your feed url
    $feed = 'http://[color=red]FEED URL';[/color]
with something like
Code: [Select]
    // Your feed url
    $feed = 'http://simpleportal.net/index.php?type=rss;action=.xml';
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: newtoallthis on September 02, 2011, 05:05:13 PM
hmm.  In what way does it not work?
Even when you replace
Code: [Select]
    // Your feed url
    $feed = 'http://[color=red]FEED URL';[/color]
with something like
Code: [Select]
    // 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.
Title: Re: Display MediaWiki RSS Feed In Simple Portal Block
Post by: AngelinaBelle on September 07, 2011, 08:05:47 AM
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.
SimplePortal 2.3.8 © 2008-2024, SimplePortal