public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $this->pluginTemplate = '/news/feed.plug.html'; $default = array('limit' => 5, 'categoryid' => null); $settings = array_merge($default, $this->attributes()); $articles = new Model_News_Article(); if (!is_null($settings['categoryid'])) { if (!is_array($settings['categoryid'])) { $settings['categoryid'] = array($settings['categoryid']); } if (!in_array(0, $settings['categoryid'])) { $articles->where('categoryid IN ?', $settings['categoryid']); } } $articles->where('pubdate <= ?', Typeframe::Now()); $articles->where('expdate >= ? OR expdate = ? OR expdate IS NULL', Typeframe::Now(), '0000-00-00 00:00:00'); $articles->where('status = ?', 'published'); $articles->limit($settings['limit']); $data = $data->fork(); $data['header'] = $settings['header']; $data['articles'] = $articles; parent::output($data, $stream); }
<?php /** * Typeframe News application * * client-side rss controller */ // set the appropriate content type header('Content-Type: application/rss+xml'); // set the template Typeframe::SetPageTemplate('/news/rss.xml'); // add title, description, link, and lastbuild date to template $pm->setVariable('title', TYPEF_TITLE); $pm->setVariable('description', TYPEF_TITLE . ' News'); $pm->setVariable('link', 'http://' . $_SERVER['HTTP_HOST']); $pm->setVariable('lastbuild', date('D, d M Y H:i:s T')); // get articles; limit to published if non-admin $articles = new Model_News_Article(); $articles->where('pubdate <= ?', Typeframe::Now()); $articles->limit('0, 10'); // add articles to template $pm->setVariable('items', $articles);