SimplePortal

Customization => Custom Coding => Topic started by: Mick. on January 30, 2010, 08:17:34 PM

Title: RSS code clean up in PHP
Post by: Mick. on January 30, 2010, 08:17:34 PM
I grabbed this from the forums and i removed the description and images.  All i wanted is a simple title feeds.

The problem is, it open in a new page.  Can you make it to open in same window and ability to show 5 titles?

Code: [Select]
   global $rss_data, $rss_current, $rss_counter;

   $parameters[0] = 'http://www.chevyavalancheclub.com/resources_page/blogs/index.php?format=feed&type=rss&title=';

   if (empty($parameters[0]))
      return;
   else
      $feed = $parameters[0];

   $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")))
      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))
      return;

 
    if (!empty($rss_data['IMAGE']))
      echo '<a href="', $rss_data['LINK'], '" target="_blank"><img src="', $rss_data['IMAGE']['URL'], '" align="middle" alt="', $rss_data['IMAGE']['TITLE'], '" /></a>', $rss_data['TITLE'], '<br /><br />';

 

   if (isset($rss_data['ITEMS']))
   {
      if (count($rss_data['ITEMS']) > 0)
      {
         for($i = 0; $i < count($rss_data['ITEMS']); $i++)
         {
            echo '<span style="font-weight: bold;"><a href="', $rss_data['ITEMS'][$i]['LINK'], '" target="_blank">', $rss_data['ITEMS'][$i]['TITLE'], '</a></span><br />';
           
            if ($i != count($rss_data['ITEMS']) - 1)
               echo '<hr />';
         }
      }
      else
         return;
   }
Title: Re: RSS code clean up in PHP
Post by: Mick. on January 30, 2010, 08:19:38 PM
Ooops, nevermind, i figured it out.
Title: Re: RSS code clean up in PHP
Post by: kcmartz on April 16, 2010, 07:52:10 PM
What did you do?
Title: Re: RSS code clean up in PHP
Post by: MultiformeIngegno on April 20, 2010, 01:36:25 AM
Me too is interested on this! :D
Title: Re: RSS code clean up in PHP
Post by: kcmartz on June 07, 2010, 01:44:33 PM
Blue?
SimplePortal 2.3.8 © 2008-2024, SimplePortal