Hi all,
I'm trying to generate a news feed with Zend_Feed respectively
Zend_Feed_Builder, running ZF 1.7.6. I have encountered the following
problems (sample code see below):
------------------
How do I set the updatePeriod? e.g.
<sy:updatePeriod>hourly</sy:updatePeriod>
------------------
How do I set the publication date (pubDate) per post item? e.g.
<pubDate>Thu, 08 Jan 2009 12:43:10 +0000</pubDate>
$feedArray = array(
'entries' => array(
array(
'published' => 1235670030
'pubDate' => 1235670030
'lastUpdate' => 1235673630
Neither 'published' nor 'pubDate' will work (ok, both fields are no
longer documented in the ZF API, I know...).
The only field that gets generated is:
<updated>2009-02-26T18:42:34+01:00</updated>
------------------
Why is the field 'description' required? Some RSS clients just display
the description (e.g. Firefox, Apple Mail), others display the content
even if there is a description present (e.g. Safari). Personally I
prefer displaying the full content. But with Zend_Feed there doesn't
seem to be a way of omitting the description.
------------------
RSS 2.0 Problem (looks OK in Atom 1.0)...
RSS does not validate due to missing 'link' tag. In Atom 1.0 it looks
like this:
<link rel="self" href="http://www.onlime.ch/news/feed" hreflang="de-
ch"/>
Known RSS feeds that validate have a 'atom:link' tag, e.g.:
<atom:link href="http://www.onlime.ch/feed" rel="self"
type="application/rss+xml" />
The 'atom:link' tag does not get generated by Zend_Feed_Builder. Is
there a way of adding extra custom defined tags next to the features
supported by Zend_Feed_Builder?
Validators give me the following errors:
* content:encoded should not contain relative URL references
* Missing atom:link with rel="self"
------------------
How do I set an author/editor per post item? e.g.
<dc:creator>iezzip</dc:creator>
------------------
'author' field seems to act differently in Atom and RSS.
valid Atom:
<author>
<name>Philip Iezzi</name>
</author>
invalid RSS:
<managingEditor>(Philip Iezzi)</managingEditor>
The feed setup should be transparent in Zend_Feed_Builder and both
output (rss or atom) should be valid. Or am I wrong here?
------------------
$feed->send() produces output of Content-Type "application/rss+xml"
respectively "application/atom+xml".
Looks good! But is this really the recommended standard and do all
modern browsers already support these content types?
Can we call "application/xml" for RSS/Atom the "old deprecated way"?
So many feeds out there deliver their content as "application/xml".
Any reason of doing so?
==================
I have used the following validators:
http://feedvalidator.org/ (service is currently down!)
http://validator.w3.org/feed/
You'll find my test feeds here, ready to be validated:
http://www.onlime.ch/news/feed - Atom 1.0
http://www.onlime.ch/news/rss - RSS 2.0
And that's my complete action code:
------------------
public function feedAction()
{
$this->_helper->viewRenderer->setNoRender();
$this->_helper->layout->disableLayout();
// configuration
$baseUrl = 'http://www.onlime.ch';
// get recent news
$newsTbl = new News();
$select = $newsTbl->select();
$select->order('post_date DESC')
->limit(10);
$news = $newsTbl->fetchAll($select);
$feedArray = array(
'title' => 'Onlime Webhosting News',
'link' => $baseUrl.'/news/feed,
'author' => 'Philip Iezzi',
'description' => 'Newsblog von Onlime Webhosting',
'language' => 'de-ch',
'charset' => 'utf-8',
'generator' => 'Zend Framework Zend_Feed',
'entries' => array()
);
foreach ($news as $post) {
$postDate = new Zend_Date($post->post_date,
Zend_Date::ISO_8601);
if (!isset($feedArray['lastUpdate'])) {
$feedArray['lastUpdate'] = $postDate-
>get(Zend_Date::TIMESTAMP);
}
$feedArray['entries'][] = array(
'title' => $post->post_title,
'link' => $baseUrl.'/index/news/id/' . $post->id,
'guid' => $baseUrl.'/index/news/id/' . $post->id,
'description' => $post->post_description,
'published' => $postDate->get(Zend_Date::TIMESTAMP),
'lastUpdate' => $postDate->get(Zend_Date::TIMESTAMP),
'content' => $post->post_content
);
}
$feed = Zend_Feed::importArray($feedArray, 'atom'); // resp. 'rss'
// send feed XML to client
$feed->send();
}
------------------
Sorry about that bunch of questions. Hope you can give me some hints.
Thanks a lot!
Regards,
Philip