0

I am quite new in Zend Framework and RSS too. I would like to create on my site RSS feed (of course available to the user in XML file). I have created RssController and corresponding view: rss/index.phtml. XML file generation works fine for me.

In RssControllers I have indexAction:

public function indexAction() 
{       
    $feedData = array(...);

    $feed = Zend_Feed::importArray ( $feedData, 'rss' ); 
    $rssFeed = $feed->saveXML();

    $fh = fopen("rss.xml", "w");
    fwrite($fh, $rssFeed);
    fclose($fh);
}

As you can guess, my rss.xml file generates every time when the mysite/rss is visited. I would like to, if this possible, create RSS feed autoupdating in some time interval. And of course, not generating every time when rss subsite is visited. How can I do something like this?

woyaru
  • 5,544
  • 13
  • 54
  • 92

2 Answers2

0

Hum iam not sure what you want but:

you dont need the file handler..

// Disable VIEW/Layout 
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);

$feed = Zend_Feed::importArray ( $feedData, 'rss' ); 
echo $feed->send();

So the Browser gets "XML" instead of an HTML or what ever..

opHASnoNAME
  • 20,224
  • 26
  • 98
  • 143
  • Earlier I have done just something similar to your code. And I don't know which solution is correct. Now I want to create a few xml files with different content from my site. And I thought to generate xml files in my `RssController`. I am afraid of this if my rss will send new articles to rss readers every time when some article will apear. Or only when the `rss` subsite will be visited? Maybe I don't understand how something in rss works... – woyaru May 24 '12 at 16:43
  • ehm RSS is not PUSH it is PULL, the client is requesting the Feed. – opHASnoNAME May 24 '12 at 16:51
0

You have three ways to update your RSS:

1 - Working with an asynchronous system

2 - Insert the URL of your controller into a CRON system (crontab linux or task scheduler windows) and make requests when you want.

3 - Create a Zend_Action_Helper and when the page is accessed, you call this Action.

Tiarê Balbi
  • 1,480
  • 1
  • 23
  • 32