Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

RSSWidget uses deprecated DataObjectSet


Reply

5 Posts   687 Views

Avatar
joko

24 September 2012 at 9:50am Community Member, 6 Posts

Hi,

I'm trying to integrate a RSS-Feed of a blog on my Site, running Silverstripe 3.0.2 with the actual blog module from github. But the RSSWidget in code/widgets uses the deprecated DataObjectSet in the function getFeedItems() so it doesn't work.

   function getFeedItems() {
         $output = new DataObjectSet();

         // Protection against infinite loops when an RSS widget pointing to this page is added to this page
         if(stristr($_SERVER['HTTP_USER_AGENT'], 'SimplePie')) {
            return $output;
         }

         include_once(Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/simplepie.inc'));

         $t1 = microtime(true);
         $feed = new SimplePie($this->AbsoluteRssUrl, TEMP_FOLDER);
         $feed->init();
         if($items = $feed->get_items(0, $this->NumberToShow)) {
            foreach($items as $item) {

               // Cast the Date
               $date = new Date('Date');
               $date->setValue($item->get_date());

               // Cast the Title
               $title = new Text('Title');
               $title->setValue($item->get_title());

               $output->push(new ArrayData(array(
                  'Title' => $title,
                  'Date' => $date,
                  'Link' => $item->get_link()
               )));
            }
            return $output;
         }
      
   }

I tried changing to ArrayList but without success.

Is there an update of this widget to be expected?

Thank you for any help.

joko

Avatar
joko

28 September 2012 at 4:19am Community Member, 6 Posts

No suggestions from anyone?

Avatar
Willr

30 September 2012 at 6:31pm Forum Moderator, 5511 Posts

You may wish to add this as an issue on the github account - https://github.com/silverstripe/silverstripe-blog/issues. That way the developers will be notified of the problem. Better yet, submit a pull request to solve the issue. I would imagine all you need to do is swap it for ArrayList as you said, what was the next error you got?

Avatar
joko

30 September 2012 at 8:49pm Community Member, 6 Posts

thanks for your answer, Willr. Turns out the next error has been a problem with the widgetArea which I have solved since.
Swapping DataObjectSet to ArrayList in RSSWidget.php works fine now. Issue solved.

Avatar
shrike

30 September 2012 at 10:28pm Community Member, 15 Posts

Joko, how did you manages to solve this? I got some nasty errors from simplepie when using code based on RSSWidget.php (wanted to create new RSS-feed from external source). I changed the DataObjectSet to ArrayList, but got "deprecated" error notice. Did you change anything else on the code?