»  Home  »  Web Technologies  »  Syndicating Content with RSS and ArticleLive
 »  Home  »  Programming  »  Syndicating Content with RSS and ArticleLive
 »  Home  »  ArticleLive  »  Syndicating Content with RSS and ArticleLive
Syndicating Content with RSS and ArticleLive
By Jordie Bodlay | Published 07/19/2006 | Web Technologies , Programming , ArticleLive | Rating: ratingfullratingfullratingfullratingfullratingempty Unrated |
Using an RSS Feed as a Panel in ArticleLive

I will now demonstrate how to include a feed as a panel in ArticleLive. The first step is to include the Magpie RSS files. Open up your init.php file (in the base directory of ArticleLive) and locate this code near the top:

ob_start();

Place the include after this line, so it looks like this:

ob_start();
include_once('magpierss/rss_fetch.inc');

Now that we have included the files, the functions will be available to use throughout the entire application. This also means that we can include multiple feeds without including the file more than once.

We now need to create a new panel file set. Navigate to /templates/{your template}/Panels/ and create 2 new files; InterspireArticles.html and InterspireArticles.php (the file names should be exact).

InterspireArticles.php will look like this:

<?php
/*******************************************\
**
*Generic ArticleLive Panel Parsing Class*
**
\*******************************************/
$panelClass = "AL_INTERSPIREARTICLES_PANEL";
if(!class_exists($panelClass)){
    CLASS AL_INTERSPIREARTICLES_PANEL
    {
        var $_htmlFile;
        function AL_INTERSPIREARTICLES_PANEL($HTMLFile)
        {
            $this->_htmlFile = $HTMLFile;
            $tmp = explode("/",$HTMLFile);
            $lastkey = sizeof($tmp)-1;
            $filename = str_replace(".html","",$tmp[$lastkey]);
            $this->_filename = $filename;
        }
        function ParsePanel()
        {
            $htmlPanelData = "";
            $parsedPanelData = "";
            if(file_exists($this->_htmlFile))
            {
                if($fp = @fopen($this->_htmlFile, "rb"))
                {
                    while(!feof($fp))
                    $htmlPanelData .= fgets($fp, 4096);
                    @fclose($fp);
                }
            }
            $rss = fetch_rss("http://www.interspire.com/content/articlerss.php");
            $GLOBALS['title'] = $rss->channel['title'];
            foreach ($rss->items as $item) {
                $href = $item['link'];
                $title = $item['title'];
                $GLOBALS['ArticleList'] .='<div class="ListItem"><a href="'.$href.'" target="_blank">'.$title.'</a></div>';
            }
            $parsedPanelData = $GLOBALS["AL_CLASS_TEMPLATE"]->ParseGL($htmlPanelData);
            return $parsedPanelData;
        }
    }
}
?>

Our InterspireArticles.html file will have the following content:

<table class="Panel RootArticleCategoriesPanel" id="Table1">
      <tr>
            <td class="Heading">
                 
            </td>
      </tr>
      <tr>
            <td style="padding:10px  0px  10px  0px ; ">
                 
            </td>
      </tr>
</table>

Now all we need to do is open up the directory /templates/{your template}/ and place the placeholder

[Panel not found: 'InterspireArticles']
in the appropriate place in the panels HTML code.

We want it to appear on the top of the right hand side, so we will place it before

[Panel not found: 'DefaultRightColumnPanel']
in all the main .html files such as Default.html, Articles.html, Blogs.html etc.

Note: The placeholder is determined by the File name. If you created a panel with the file names MyPanel.php and MyPanel.html, then you would use

[Panel not found: 'MyPanel']
as the placeholder.

You panel will now show up with the links straight from our the feed. This can be used for any RSS feed and allows your site to be updated with the latest news and information automatically.

Pages: « Back  1 2 3 4  Next » 
Web designers: Learn how to attract more clients and profit like the big guys. Subscribe to our newsletter.