woyaru
woyaru

Reputation: 5634

how to create rss feed with autoupdate in Zend

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?

Upvotes: 0

Views: 296

Answers (2)

Tiarê Balbi
Tiarê Balbi

Reputation: 1509

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.

Upvotes: 0

opHasNoName
opHasNoName

Reputation: 20736

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..

Upvotes: 0

Related Questions