December 13, 2005

Using DOMIT! RSS

PHP & Web Development — Sarah King

I've worked with DOMIT! because it's part of the Mambo and Joomla CMS systems so I expected this to be a doddle. Sorry, it wasn't. There were 2 undefined constants and one code defect which all took time to identify.

There is no doubt that the code in DOMIT! is far more exhaustive than that of Magpie but, really, you don't need it if all you're planning to do is parse an RSS onto a webpage.

To use DOMIT!

  1. Visit the Engage Interactive site and download

    and yes, you do need both.

  2. Unzip the two packages into the same "domit" folder on your hard drive and then upload onto your site using FTP.
  3. Decide which page you want to add the feed to and open the appropriate file in your favourite editor (mine is Zend).
  4. Now you just have to add these lines to the file, save and upload!
    PHP:
    1. require_once('domit/xml_domit_rss_lite.php');
    2. $rssdoc =& new xml_domit_rss_document_lite('http://www.propertyinvestor.info/articles/feed/');
    3.  
    4. //get number of channels
    5. $numChannels = $rssdoc->getChannelCount();
    6.    
    7. //set up a loop to iterate through each channel
    8. for ($i = 0; $i <$numChannels; $i++)
    9. {
    10.     //obtain a reference to the current channel
    11.     $currChannel =& $rssdoc->getChannel($i);
    12.       
    13.     //echo link of channel
    14.     $output = "<center><table cellspacing='0' cellpadding='0'>
    15. <tr><th valign='top'><a href=" . $currChannel->getLink() . ">".$currChannel->getTitle()."</a> - ".$currChannel->getDescription()."</th></tr>";
    16.  
    17.     //get number of items
    18.     $numItems = $currChannel->getItemCount();
    19.     if ($numItems> 5) $numItems = 5;
    20.  
    21.     //set up a loop to iterate through each item
    22.     for ($j = 0; $j <$numItems; $j++)
    23.     {
    24.       //get reference to current item
    25.         $currItem =& $currChannel->getItem($j);
    26.         $title = $currItem->getTitle();
    27.         $output .= "<tr><td><a href='" . $currItem->getLink() . "' title=\"{$title}\">{$title}</a></td></tr>";
    28.     }
    29. }
    30. $output .= "</table></center>";
    31. echo $output;

Changes

  • php_text_cache.php, line 112, truthval should be $truthval
  • php_http_exceptions.php, line 31, make this change
    PHP:
    1. $GLOBALS['HTTP_Exception_mode'] = 1;
    2. //$GLOBALS['HTTP_Exception_mode'] = HTTP_ONERROR_RETURN;

  • xml_domit_rss_shared.php, line 914, make this change
    PHP:
    1. $GLOBALS['DOMIT_RSS_Exception_mode'] = 1;
    2. //$GLOBALS['DOMIT_RSS_Exception_mode'] = DOMIT_RSS_ONERROR_RETURN;

Also on this site

2 Comments »

  1. Hi Sarah,

    Found this page while researching a bug report in the Joomla tracker regards DOMIT.

    Your fixes will be included in the upcoming Joomla! 1.0.6 release with the fix attributed in teh changelog as follows:
    # Fixed DOMIT bugs identified by [sarahk]

    Thanks for your efforts, I hope you have reported it to DOMIT.


    Rey Gigataras
    —————————————
    http://www.joomla.org
    Software Coding and Design
    [Stability Team Leader]

    http://www.opensourcematters.org
    Open Source Matters, because it is about helping others!!

    Comment by Rey Gigataras — January 9, 2006 @ 4:02 am

  2. I was just reviewing the demo page and found it was hanging. I haven’t dug through too much but it appears to have a problem with the WordPress v2 feeds. I probably need to upgrade to the absolute latest version and then send feedback if the problem still exists.

    So, if you are using Domit! and your site suddenly dies, it could be the feed rather than your programming.

    Comment by sarahk — May 8, 2006 @ 2:29 pm

Leave a comment

RSS feed for comments on this post. TrackBack URI

Pages

Categories:

Other Resources

Subscribe in NewsGator Online
GeoURL